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

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -