Forum


03:34

20/02/2009

hello, I want use the button "search" in the navigation bar but nothing work. I use "getpostdata' to see what is post.
bellow, it's my programm.
<?php
include($_SERVER['DOCUMENT_ROOT']."/paiement/include/dbconfig.php");
include($_SERVER['DOCUMENT_ROOT']."/paiement/include/JSON.php");
$json = new Services_JSON();
$page = $_GET['page']; // get the GETed page
$limit = $_GET['rows'];$sidx = $_GET['sidx'];
$sidx = $_GET['sidx'];
$sord = $_GET['sord'];
if(!$sidx) $sidx =1;
$wh ="";
$where_recherche = "";
$where_recherche_count = "";
if(isset($_REQUEST['searchField'])){
$field = $_REQUEST['searchField'];
switch ($field) {
case "num_inform":
$field = "fofacent.".$field;
break;
case "nom_banque":
$field = "fobanque.".$field;
break;
default:
$field = "";
break;
}
}
else {
$field = "fofacent.num_inform";
}
if (isset($_REQUEST['searchString'])) {
$value = $_REQUEST['searchString'];
}
else {
$value = "1665";
}
if (isset($_REQUEST['searchOper'])) {
$oper = $_REQUEST['searchOper'];
switch ($oper) {
case "eq":
if(is_numeric($value)) {
$wh = " = ".$value;
} else {
$wh = " = '".$value."'";
}
break;
case "ne":
if(is_numeric($value)) {
$wh = " <> ".$value;
} else {
$wh = " <> '".$value."'";
}
break;
case "lt":
if(is_numeric($value)) {
$wh = " < ".$value;
} else {
$wh = " < '".$value."'";
}
break;
case "le":
if(is_numeric($value)) {
$wh = " <= ".$value;
} else {
$wh = " <= '".$value."'";
}
break;
case "gt":
if(is_numeric($value)) {
$wh = " > ".$value;
} else {
$wh = " > '".$value."'";
}
break;
case "ge":
if(is_numeric($value)) {
$wh = " >= ".$value;
} else {
$wh = " >= '".$value."'";
}
break;
case "bw":
$wh = " LIKE '".$value."%'";
break;
case "ew":
$wh = " LIKE '%".$value."'";
break;
case "cn":
$wh = " LIKE '%".$value."%'";
break;
default :
$wh = "";
break;
}
$where_recherche = " AND ".$field.$wh;
$where_recherche_count = $field.$wh;
}
else {
$oper = " = ";
$wh = $oper.$value;
$where_recherche = " AND ".$field.$wh;
$where_recherche_count = $field." ".$oper." '".$value."'";
}
// Connection vers la base de données
$db = mysql_connect($dbhost, $dbuser, $dbpassword)
or die("Connection Error: " . mysql_error());
mysql_select_db($database) or die("Error conecting to db.");
$result = mysql_query("SELECT COUNT(*) AS count FROM fofacent WHERE ".$where_recherche_count);
$row = mysql_fetch_array($result,MYSQL_ASSOC);
$count = $row['count'];
if( $count >0 ) {
$total_pages = ceil($count/$limit);
} else {
$total_pages = 0;
}
if ($page > $total_pages) $page=$total_pages;
$start = $limit*$page - $limit; // Ne pas mettre $limit*($page - 1)
if ($start<0) $start = 0;
$SQL = "SELECT fofacent.cod_typfac, fofacent.cod_etafac, fofacent.dat_annee, fofacent.cod_banque, fobanque.nom_banque, fofacent.cod_fourni, fofacent.nom_foureg, fotypfac.cod_sens, fofacent.mnt_reg, fournis.cod_devise,fofacent.dat_echean, fofacent.num_facfou, fofacent.num_inform, fofacent.num_factur, fofacent.cod_etat FROM fofacent, fobanque, fotypfac, fournis WHERE (fobanque.cod_banque = fofacent.cod_banque AND fotypfac.cod_typfac = fofacent.cod_typfac AND FOURNIS.COD_ETAFOU = FOFACENT.COD_ETAFOU AND FOURNIS.COD_FOURNI = FOFACENT.COD_FOURNI ".$where_recherche.") ORDER BY ".$sidx." ".$sord. " LIMIT ".$start." , ".$limit;
$result = mysql_query( $SQL ) or die("Could not execute query.".mysql_error());
$responce->page = $page;
$responce->total = $total_pages;
$responce->records = $count;
$i=0;
while($row = mysql_fetch_array($result,MYSQL_ASSOC)) {
$responce->rows[$i]['id']=array($row['num_factur'].'-'.$row['cod_etafac'].'-'.$row['cod_typfac'].'-'.$row['dat_annee']); //Définition de la clé de l'enregistrement réccupéré
$responce->rows[$i]['cell']=array($row['cod_banque'],$row['nom_banque'],$row['cod_fourni'],$row['nom_foureg'],$row['cod_sens'],$row['mnt_reg'],$row['cod_devise'],$row['dat_echean'],$row['num_facfou'],$row['num_inform']);
$i++;
}
echo $json->encode($responce);//envoie des informations du GRID
mysql_close($db);
?>
I don't uderstand how can I do my search. nothing work.
If you have an idea?!!
thank you for your help?!
Regards
04:02

Moderators
30/10/2007

Hello,
Sorry but we consider here a jqGrid problems and not PHP code. The examples are just examples. I recommend to begin just with very simple data and code.
Regards
Tony
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
04:20

20/02/2009

Hello Tony,
I know. I work on jqgrid since 1 month. I work with a simple cod and now, my boss want that I programm the search function!
That's why I want some help, because i don't understand why I can't use post data for search.
When I use gestpost data, it's written :
nd: 1238577429279,_search: true,rows: 10,page: 1,sidx: cod_banque,sord: asc,searchField: num_inform,searchOper: eq,searchString: 1116,
that's why in my programm, i want use these three parameters (searchField: ,searchOper: ,searchString)
If an another method exists to success my search can you explain me please.
It's very important. I don't only copy out you cod but I use it to success my programm.
thank you for your help!
Regards
Aurore
04:26

Moderators
30/10/2007

Hello,
Did you see _search: true
If this is true the serch is activated and you can use the above parameters.
If _search:false you are not in search and you can use a condition for this - right?
Why not read the docs?
Regards
Tony
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
Most Users Ever Online: 715
Currently Online:
109 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66