php - I face error in my IF ELSE -


i new in php. face problem in if else. if else statement not working. have 2 sql queries. in starting have simple query fetch client_id against opinion_id , store result of thi squery in variable $opinion_id

after have sql query fetch opinion_id against client_id fetched previous query.

my 3rd query if there no client_id against opinion_idwith reference 1st query print record against thatopinion_id`

in if else have problem execute else part if client_id null or not.

my remaining php code is

$opinion = array();  while($row1 = mysql_fetch_assoc($result1)) {             $opinion[]= $row1['opinion'];     $action[]= $row1['atitle'];     $long_term[]= $row1['ltitle'];     $outlook[]= $row1['otitle'];     $rating_type[]= $row1['ttitle'];     $short_term[]= $row1['stitle'];   } 

html code is

<?php include ("connection.php"); include ("sqlquery.php");     ?>  <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <style> table {     border-collapse: collapse; }  table, td, th {     border: 1px solid black; } </style> <title>untitled document</title> </head>  <body> <div style="margin-top:auto; width:auto;font-family:'times new roman', times, serif; text-align:left; font-size:12px; text-align:center"> <table width="657">         <tr>             <td width="225"> <strong>opinion</strong></td>             <td width="62"> <strong>action</strong></td>             <td colspan="4"><strong>ratings</strong></td>             <td width="54"><strong>outlook</strong></td>             <td width="67"><strong>rating type</strong></td>         </tr>         <tr>           <td width="225">&nbsp;</td>           <td width="62">&nbsp;</td>           <td colspan="2"><b>long term</b></td>           <td colspan="2"><b>short term</b></td>           <td width="54">&nbsp;</td>           <td width="67">&nbsp;</td>         </tr>         <tr>           <td width="225">&nbsp;</td>           <td width="62">&nbsp;</td>           <td width="52"><b>current</b></td>           <td width="45"><b>previous</b></td>           <td width="49"><b>current</b></td>           <td width="51"><b>previous</b></td>           <td width="54">&nbsp;</td>           <td width="67">&nbsp;</td>         </tr>         <?php         ($i=0; $i<count($opinion); $i++) {     //if ($opinion[$i] == "")continue;         ?>       <tr>            <td><?php echo $opinion[$i]?></td>           <td><?php echo $action[$i] ?></td>           <td><?php echo $long_term[$i] ?></td>           <td><?php //echo $p_long_term[$i]?></td>           <td><?php echo $short_term[$i] ?></td>           <td><?php //echo $p_short_term[$i] ?></td>           <td><?php echo $outlook[$i] ?></td>           <td><?php echo $rating_type[$i] ?></td>         </tr>          <?php         } ?>  </table>  <tr>           <td width="225"><?php // echo $liaison_one_chunks[0]?></td>           <td width="62"><?php //echo $liaison_one_chunks[1]?></td>           <td width="52"><b><?php //echo $liaison_one_chunks[2]?></b></td>           <td width="45"><b><?php //echo $liaison_one_chunks[3]?></b></td>           <td width="49"><b><?php //echo $liaison_one_chunks[4]?></b></td>          </tr>  <table>   </table>         </div> </body> </html> 

before write:

if($opinion_id == null){     $query = $q_opinion1;     }     else     {          $query = $q_opinion;     }   $result1 = mysql_query($query) or die; 

you must have returned value query or otherwise in order use in $opinion_id. instance, did try echo $opinion_id , see got?

something like:

$opinion_id = $returned_value; if($opinion_id == null){     $query = $q_opinion1;     }     else     {          $query = $q_opinion;     }   $result1 = mysql_query($query) or die; 

Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -