Jump to content

Help with if statement


ansonb

Recommended Posts

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.

Link to comment
Share on other sites

You are not concatenating the string and variables properly.

 

if ($row['host'] == "")
                {
                 echo $row['show_name'] . " with " . $row['host'];
                }
              else
                {
                 echo $row['show_name'];
                }

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.