ansonb Posted February 4, 2012 Share Posted February 4, 2012 I need help with my if/else statement. function show_list() { $query = "SELECT show_id,show_name,host,description_short,show_graphic1 FROM shows"; $result = mysql_query($query) or die(mysql_error()); echo "<table>"; while($row = mysql_fetch_array($result)) { echo "<tr> <td rowspan='3' width='155' class='show_image'> <a href='". $site ."show_page.php?show_id=". $row['show_id'] ."'> <img src='". $site ."images/". $row['show_graphic1'] ."' height='150' width='150'></img></a> </td> <td class='show_name'> <h1>"; if ($row['host'] == "") { echo $row['show_name']" with " $row['host']; } else { echo $row['show_name']; } echo " </h1> </td> </tr> <tr> <td height='100'>" . $row['description_short'] . "</td> </tr> <tr> <td align='right'> <a href='". $site ."show_page.php?show_id=". $row['show_id'] ."'>More Info</a> </td> </tr>"; } echo "</table>"; } This function is for a page showing a list of shows from a database. Not all shows have a host. So it does not need to show "with host name" for those shows. I tried if / else statement stating that if there "is" data in the row to display one thing and if there "is not" data in the row to display another. Here is that piece of code. if ($row['host'] == "") { echo $row['show_name']" with " $row['host']; } else { echo $row['show_name']; } I keep getting this error "Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in /home/ansonb/lwr_config.php on line 46" What am I doing wrong ? I'm sure it is something simple, I just can't figure it out. Quote Link to comment https://forums.phpfreaks.com/topic/256404-help-with-if-statement/ Share on other sites More sharing options...
AyKay47 Posted February 4, 2012 Share Posted February 4, 2012 You are not concatenating the string and variables properly. if ($row['host'] == "") { echo $row['show_name'] . " with " . $row['host']; } else { echo $row['show_name']; } Quote Link to comment https://forums.phpfreaks.com/topic/256404-help-with-if-statement/#findComment-1314493 Share on other sites More sharing options...
ansonb Posted February 4, 2012 Author Share Posted February 4, 2012 Thank You. Duh, I knew it was simple. Quote Link to comment https://forums.phpfreaks.com/topic/256404-help-with-if-statement/#findComment-1314507 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.