Afin de pouvoir m'aider,
voici maintenant le code php de "chargementbagues.php"
D'avnce un immense merci pour ton habituelle aide...
<?php
session_start();
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* libellés types
*/
$libelle = array();
$libelle[1] = array ("WG", "YG", "PT");
$libelle[3] = array ("", "01", "02", "03", "04");
$libelle[6] = array ("simple", "accompagné");
$libelle[8] = array ("", "ON", "OFF");
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Easy set variables
*/
/* Array of database columns which should be read and sent back to DataTables. Use a space where
* you want to insert a non-database field (for example a counter or static image)
*/
$aColumns = array();
$aColumns [] = 'ref_monture'; /* 00 */
$aColumns [] = 'finition'; /* 01 */
$aColumns [] = 'modele'; /* 02 */
$aColumns [] = 'sous_modele'; /* 03 */
$aColumns [] = 'carat'; /* 04 */
$aColumns [] = 'descriptif'; /* 05 */
$aColumns [] = 'type_solitaire'; /* 06 */
$aColumns [] = 'PV_HT'; /* 07 */
$aColumns [] = 'statut'; /* 08 */
$aColumns [] = 'pierre_min_carat'; /* 09 */
$aColumns [] = 'pierre_max_carat'; /* 10 */
$aColumns [] = 'vue_01'; /* 11 */
$aColumns [] = 'vue_02'; /* 12 */
$aColumns [] = 'vue_03'; /* 13 */
$aColumns [] = 'vue_04'; /* 14 */
$aColumns [] = 'vue_05'; /* 15 */
$aColumns [] = 'max_carat_rond'; /* 14 */
$aColumns [] = 'max_carat_marquise'; /* 17 */
$aColumns [] = 'max_carat_emeraude'; /* 18 */
$aColumns [] = 'max_carat_radiant'; /* 19 */
$aColumns [] = 'max_carat_ovale'; /* 20 */
$aColumns [] = 'max_carat_poire'; /* 21 */
$aColumns [] = 'max_carat_coeur'; /* 22 */
$aColumns [] = 'max_carat_aascher'; /* 23 */
$aColumns [] = 'max_carat_cs'; /* 24 */
$aColumns [] = 'max_carat_autre'; /* 25 */
/* bouton d'aide */ /* 26 */
/* Indexed column (used for fast and accurate table cardinality) */
$sIndexColumn = "ref_monture";
/* DB table to use */
$sTable = "monture_data";
/* Database connection information */
$gaSql['user'] = "celinni_com";
$gaSql['password'] = "K28JxQVe";
$gaSql['db'] = "celinni_com";
$gaSql['server'] = "celinni.com.mysql";
/*
* MySQL connection
*/
$gaSql['link'] = mysql_pconnect( $gaSql['server'], $gaSql['user'], $gaSql['password'] ) or
die( 'Could not open connection to server' );
mysql_select_db( $gaSql['db'], $gaSql['link'] ) or
die( 'Could not select database '. $gaSql['db'] );
mysql_set_charset( 'utf8' );
/*
* Paging
*/
$sLimit = "";
if ( isset( $_GET['iDisplayStart'] ) && $_GET['iDisplayLength'] != '-1' )
{
$sLimit = "LIMIT ".intval( $_GET['iDisplayStart'] ).", ".
intval( $_GET['iDisplayLength'] );
}
/*
* Ordering
*/
$sOrder = "";
if ( isset( $_GET['iSortCol_0'] ) )
{
$sOrder = "ORDER BY ";
for ( $i=0 ; $i<intval( $_GET['iSortingCols'] ) ; $i++ )
{
if ( $_GET[ 'bSortable_'.intval($_GET['iSortCol_'.$i]) ] == "true" )
{
$sOrder .= "`".$aColumns[ intval( $_GET['iSortCol_'.$i] ) ]."` ".
($_GET['sSortDir_'.$i]==='asc' ? 'asc' : 'desc') .", ";
}
}
$sOrder = substr_replace( $sOrder, "", -2 );
if ( $sOrder == "ORDER BY" )
{
$sOrder = "";
}
}
/*
* Filtering
* NOTE this does not match the built-in DataTables filtering which does it
* word by word on any field. It's possible to do here, but concerned about efficiency
* on very large tables, and MySQL's regex functionality is very limited
*/
$sWhere = "";
/* Individual column filtering */
$sColumnWhere = "";
for ( $i=0 ; $i<count($aColumns) ; $i++ )
{
if ( $_GET['sSearch_'.$i] != "" )
{
$aWords = preg_split('/\s+/', $_GET['sSearch_'.$i]);
$sColumnWhere .= "(";
for ( $j=0 ; $j<count($aWords) ; $j++ )
{
if ( $aWords[$j] != "" )
{
$sColumnWhere .= "`".$aColumns[$i]."` = '".mysql_real_escape_string( $libelle[ $i ][ $aWords[$j] ] )."' OR ";
}
}
$sColumnWhere = substr_replace( $sColumnWhere, "", -3 );
$sColumnWhere .= ") AND ";
}
if ( $_GET['sStart_'.$i] != "" AND $_GET['sEnd_'.$i] != "" )
{
$sColumnWhere .= "(";
$sColumnWhere .= "`".$aColumns[$i]."` >= '".mysql_real_escape_string( $_GET['sStart_'.$i] )."' AND `".$aColumns[$i]."` <= '".mysql_real_escape_string( $_GET['sEnd_'.$i] )."' ";
$sColumnWhere .= ") AND ";
}
if ( $_GET['sMin_'.$i] != "" )
{
$sColumnWhere .= "(";
$sColumnWhere .= "`".$aColumns[$i]."` <= '".mysql_real_escape_string( $_GET['sMin_'.$i] )."' ";
$sColumnWhere .= ") AND ";
}
if ( $_GET['sMax_'.$i] != "" )
{
$sColumnWhere .= "(";
$sColumnWhere .= "`".$aColumns[$i]."` >= '".mysql_real_escape_string( $_GET['sMax_'.$i] )."' ";
$sColumnWhere .= ") AND ";
}
}
if ( $sColumnWhere != "" ) {
$sColumnWhere = substr_replace( $sColumnWhere, "", -5 );
if ( $sWhere == "" ) {
$sWhere = $sColumnWhere;
} else {
$sWhere .= " AND ".$sColumnWhere;
}
}
if ( $sWhere != "" )
{
$sWhere = "WHERE ".$sWhere;
}
/*
* SQL queries
* Get data to display
*/
$sQuery = "
SELECT SQL_CALC_FOUND_ROWS `".str_replace(" , ", " ", implode("`, `", $aColumns))."`
FROM $sTable
$sWhere
$sOrder
$sLimit
";
$rResult = mysql_query( $sQuery, $gaSql['link'] ) or die(mysql_error());
/* Data set length after filtering */
$sQuery = "
SELECT FOUND_ROWS()
";
$rResultFilterTotal = mysql_query( $sQuery, $gaSql['link'] ) or die(mysql_error());
$aResultFilterTotal = mysql_fetch_array($rResultFilterTotal);
$iFilteredTotal = $aResultFilterTotal[0];
/* Total data set length */
$sQuery = "
SELECT COUNT(`".$sIndexColumn."`)
FROM $sTable
";
$rResultTotal = mysql_query( $sQuery, $gaSql['link'] ) or die(mysql_error());
$aResultTotal = mysql_fetch_array($rResultTotal);
$iTotal = $aResultTotal[0];
/*
* Output
*/
$output = array(
"sEcho" => intval($_GET['sEcho']),
"iTotalRecords" => $iTotal,
"iTotalDisplayRecords" => $iFilteredTotal,
"aaData" => array()
);
while ( $aRow = mysql_fetch_array( $rResult ) )
{
$row = array();
$row[] = trim($aRow[ 'ref_monture' ]);
$row[] = trim($aRow[ 'finition' ]);
$row[] = trim($aRow[ 'modele' ]);
$inter = trim($aRow[ 'carat' ]);
$row[] = number_format($inter, 2, ',', ' ');
$row[] = trim($aRow[ 'descriptif' ]);
$row[] = trim($aRow[ 'type_solitaire' ]);
$inter = trim($aRow[ 'PV_HT' ]);
$row[] = number_format($inter, 0, ',', ' ');
$row[] = trim($aRow[ 'statut' ]);
$inter = trim($aRow[ 'pierre_min_carat' ]);
$row[] = number_format($inter, 2, ',', ' ');
$inter = trim($aRow[ 'pierre_max_carat' ]);
$row[] = number_format($inter, 2, ',', ' ');
$row[] = trim($aRow[ 'vue_01' ]);
$row[] = trim($aRow[ 'vue_02' ]);
$row[] = trim($aRow[ 'vue_03' ]);
$row[] = trim($aRow[ 'vue_04' ]);
$row[] = trim($aRow[ 'vue_05' ]);
$inter = trim($aRow[ 'max_carat_rond' ]);
$row[] = number_format($inter, 2, ',', ' ');
$inter = trim($aRow[ 'max_carat_marquise' ]);
$row[] = number_format($inter, 2, ',', ' ');
$inter = trim($aRow[ 'max_carat_emeraude' ]);
$row[] = number_format($inter, 2, ',', ' ');
$inter = trim($aRow[ 'max_carat_radiant' ]);
$row[] = number_format($inter, 2, ',', ' ');
$inter = trim($aRow[ 'max_carat_ovale' ]);
$row[] = number_format($inter, 2, ',', ' ');
$inter = trim($aRow[ 'max_carat_poire' ]);
$row[] = number_format($inter, 2, ',', ' ');
$inter = trim($aRow[ 'max_carat_coeur' ]);
$row[] = number_format($inter, 2, ',', ' ');
$inter = trim($aRow[ 'max_carat_aascher' ]);
$row[] = number_format($inter, 2, ',', ' ');
$inter = trim($aRow[ 'max_carat_cs' ]);
$row[] = number_format($inter, 2, ',', ' ');
$inter = trim($aRow[ 'max_carat_autre' ]);
$row[] = number_format($inter, 2, ',', ' ');
$row[] = "<a href='javascript:envoiDetails(\"".trim($aRow[ 'ref_monture' ])."\");'><span class='voir'>Détails</span></a>";
$output['aaData'][] = $row;
}
echo json_encode( $output );
mysql_free_result($rResultTotal);
mysql_close($gaSql['link']);
?>
Modifié par jytest (12 Sep 2014 - 14:25)