i want to use same query for fetch all record and specific id records in php mysql -
i want fetch records if catid null , fetch specific id data if catid provided using same query here code
$catid=$_get['cat']; if($_get['cat'] = '' || $_get['cat'] = null ){ $sel="select * listings `stat`='y' , order `sno` ".$pagination->getlimitsql(); }else{ $sel="select * listings `stat`='y' , `category`='{$catid}' order `sno` ".$pagination->getlimitsql(); } $result=mysql_query($sel); $listproducts = array(); // create variable hold information while (($row = mysql_fetch_array($result, mysql_assoc)) !== false){ $listproducts[] = $row; // add row in results (data) array };
please replace =
==
if($_get['cat'] = '' || $_get['cat'] == null ){
a better approach this:
if (isset($_get['cat']) && !empty($_get['cat'])) {
Comments
Post a Comment