Bonsoir à tous.
Tout d'abord, je vus souhaite un bon weekend !
Le mien est assombri par un souci ajax...
Pouvez-vus prendre un peu de temps pour m'aider ?
J'ai beau envoyer des arguments à "chargementbagues.php",
rien n'y fait...
Ce "chargementbagues.php" ne veut pas avaler mes "iSearch_",
pourtant envoyés par la fonction url();
Merci d'avance pour votre aide !
Voici dans ma page principale "recherche30.php",
j'appelle la fnction javascript "newrecherche();"
Voici le javascript litigieux :
Voici "php/chargementbagues.php"
Modifié par jytest (03 Jun 2013 - 15:35)
Tout d'abord, je vus souhaite un bon weekend !
Le mien est assombri par un souci ajax...
Pouvez-vus prendre un peu de temps pour m'aider ?
J'ai beau envoyer des arguments à "chargementbagues.php",
rien n'y fait...
Ce "chargementbagues.php" ne veut pas avaler mes "iSearch_",
pourtant envoyés par la fonction url();
Merci d'avance pour votre aide !
Voici dans ma page principale "recherche30.php",
j'appelle la fnction javascript "newrecherche();"
Voici le javascript litigieux :
function nbreference() {
var txt = "Résultats: " + format(triref,0," ");
if (triref != maxref) {
txt += " / " + format(maxref,0," ");
}
txt += " diamants <img src='images/general/vide.gif' width='32' height='32' alt='chargement_en_cours'>";
document.getElementById("bloc2101").innerHTML= txt;
}
function resetrecherche() {
document.getElementById("bloc2101").innerHTML="Chargement <img src='images/general/roulette.gif' width='32' height='32' alt='chargement_en_cours'>";
}
function newrecherche() {
url();
var requete = creerRequete();
requete.open("GET", "php/chargementbagues.php"+argurl, true);
requete.onreadystatechange = function() {
if (requete.readyState == 4 && requete.status == 200) {
var jsonResponse = JSON.parse(requete.responseText);
liretablejson(jsonResponse);
}
}
requete.send(null);
}
function liretablejson(jtable) {
oTable = "<table cellpadding='0' cellspacing='0' border='0' class='display' id='example'>";
oTable += "<tbody>";
oCol = 0;
oLig = 0;
aData = jtable.aaData;
triref = jtable.iTotalDisplayRecords;
maxref = jtable.iTotalRecords;
for (var ilire=0; ilire < maxref; ilire++) {
Data = aData[ilire];
finition = Data[1];
switch (finition) {
case "orblanc":
matiere = "Or blanc";
break;
case "orjaune":
matiere = "Or jaune";
break;
case "platine":
matiere = "Platine";
break;
default:
matiere = "nc";
break;
}
oCellule = "<td>";
oCellule += "<div class='case'>";
oCellule += "<img src='"+doss+Data[8]+"' width='225' height='225' alt='bague'>";
oCellule += "<p class='case01'>"+Data[2]+"</p>";
oCellule += "<p class='case02'>"+Data[4]+"<br>"+matiere+"</p>";
oCellule += "<p class='case03 bold'>"+Data[6]+" €</p>";
oCellule += "<p class='case02'>"+Data[19]+"</p>";
oCellule += "</div>";
oCellule += "</td>";
if (oCol >= mCol) {
oCol = 0;
oLig++;
oTable += '</tr>';
}
if (oCol == 0) {
oTable += '<tr>';
}
oTable += oCellule;
oCol++;
}
oTable += "</tbody>";
oTable += "</table>";
nbreference();
document.getElementById("bloc31").innerHTML=oTable;
}
/code]
[code]
function url() {
argurl = "";
if (valMIN[1] != plageMIN[1] || valMAX[1] != plageMAX[1]) {
argurl += "&sStart_7=" + valMIN[1] + "&sEnd_7=" + valMAX[1];
}
if (metals != "") {
argurl += "&sSearch_1=" + metals;
}
argurl += "&sSearch_3=" + "1";
if (solitaires != "") {
argurl += "&sSearch_6=" + solitaires;
}
argurl += "&sSearch_8=" + "1";
if (argurl != "") {
argurl = argurl.replace('&','?');
}
return argurl;
}
Voici "php/chargementbagues.php"
<?php
session_start();
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* libellés types
*/
$libelle = array();
$libelle[1] = array ("orblanc", "orjaune", "platine");
$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_sertissure'; /* 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 [] = 'vue_01'; /* 09 */
$aColumns [] = 'max_carat_rond'; /* 10 */
$aColumns [] = 'max_carat_marquise'; /* 11 */
$aColumns [] = 'max_carat_emeraude'; /* 12 */
$aColumns [] = 'max_carat_radiant'; /* 13 */
$aColumns [] = 'max_carat_ovale'; /* 14 */
$aColumns [] = 'max_carat_poire'; /* 15 */
$aColumns [] = 'max_carat_coeur'; /* 16 */
$aColumns [] = 'max_carat_aascher'; /* 17 */
$aColumns [] = 'max_carat_cs'; /* 18 */
$aColumns [] = 'max_carat_autre'; /* 19 */
/* bouton d'aide */ /* 20 */
/* Indexed column (used for fast and accurate table cardinality) */
$sIndexColumn = "ref_sertissure";
/* DB table to use */
$sTable = "sertissure_data";
/* Database connection information */
$gaSql['user'] = "***";
$gaSql['password'] = "***";
$gaSql['db'] = "***";
$gaSql['server'] = "***";
/*
* 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 = "";
if ( $_GET['sSearch'] != "" )
{
$sWhere = "(";
$aWords = preg_split('/\s+/', $_GET['sSearch']);
for ( $j=0 ; $j<count($aWords) ; $j++ )
{
if ( $aWords[$j] != "" )
{
$sWhere .= "(";
for ( $i=0 ; $i<count($aColumns) ; $i++ )
{
$sWhere .= "`".$aColumns[$i]."` LIKE '%".mysql_real_escape_string( $aWords[$j] )."%' OR ";
}
$sWhere = substr_replace( $sWhere, "", -3 );
$sWhere .= ") AND ";
}
}
$sWhere = substr_replace( $sWhere, "", -5 );
$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 ( $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_sertissure' ]);
$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' ]);
$row[] = trim($aRow[ 'vue_01' ]);
$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_sertissure' ]).");'><span class='voir'>Détails</span></a>";
$output['aaData'][] = $row;
}
echo json_encode( $output );
?>
Modifié par jytest (03 Jun 2013 - 15:35)