if else condition not validating for mysql query in php mysql -


hi have small problem execution of query using if else condition. have 2 tables i.e dashboard_widget , dashboard_widget_users , in both table store unserialize configuration.users configuration dashboard_widget_users table.but if configuration null take bydefault configuration dashboard_widget table.i want use if else condition , tried unable execute properly.the condition if(!empty($empty_config)) getting satisfied if empty not getting result.thank you.

dashboard_widget_users table enter image description here

dashboard_widget table enter image description here

here php code:

$query = "select dashboard_widget_users.configuration     dashboard_widget_users     inner join yw_user on dashboard_widget_users.dsnr_yw_user = yw_user.intern     inner join dashboard_widget on dashboard_widget_users.dsnr_dashboard_widget = dashboard_widget.id     dashboard_widget_users.dsnr_yw_user =10 , dashboard_widget.id =1 ";   $result = mysql_query($query, $myconnection); if ($row = mysql_fetch_assoc($result))  {     $empty_config=$row['configuration'];     if (empty($empty_config)) {         $sql="select dashboard_widget.configuration dashboard_widget id =1";         $sql_result = mysql_query($sql, $myconnection);         $results = mysql_fetch_assoc($sql_result);           $config= unserialize($results['configuration']);     }     if (!empty($empty_config)) {         $config = unserialize($row['configuration']);          foreach($config $val)         {             //here further things.....                      }    } } 

you should check if there rows found, if so, display information, if not, display default info:

<?php $query = "select dashboard_widget_users.configuration     dashboard_widget_users     inner join yw_user on dashboard_widget_users.dsnr_yw_user = yw_user.intern     inner join dashboard_widget on dashboard_widget_users.dsnr_dashboard_widget = dashboard_widget.id     dashboard_widget_users.dsnr_yw_user =10 , dashboard_widget.id =1 ";   $result = mysql_query($query, $myconnection);  if( mysql_num_rows( $result ) > 0 ) {     // row found, display } else {     // row not found, display default } ?> 

note: should mysqli_* functions, mysql_* functions deprecated. check this link.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -