If else - need help laying out my code

Hi all

How can I add the below code into my while loop further down?

Syntax not tested

<? if $row['confirmed'] == '':
    echo "<li><strong>Venue:</strong> " . $row['venue_id'] . "</li>";
   else    
    echo "<li><strong>Venue:</strong> <a href=venue/" . $row['venue_id'] . "> . $row['venue_id'] . "</a></li>";

endif ?>

I need to replace echo "<li><strong>Venue:</strong> " . $row[‘venue_id’] . “</li>”; with if else options above.

Any suggestions?

$sql="SELECT venue_id, address, category_id, website, hits FROM tbl_venues WHERE venue_id = '".$q."'";
$result = @mysql_query($sql) or die('Error: ' . mysql_error());

while($row = mysql_fetch_array($result))
  {
  echo "<ul class='venue_box'>";
  echo "<li><strong>Venue:</strong> " . $row['venue_id'] . "</li>";
  echo "<li><strong>Address:</strong> " . $row['address'] . "</li>";
  echo "<li><strong>Type:</strong> " . $row['category_id'] . "</li>";
  echo "<li><strong>Link:</strong> <a href=index.php?url=" . $row['website'] . ">website</a></li>";

  echo "</ul>";
  }

Thank you :slight_smile:

$sql="SELECT venue_id, address, category_id, website, hits, confirmed FROM tbl_venues WHERE venue_id = '".$q."'";
$result = @mysql_query($sql) or die('Error: ' . mysql_error());

while($row = mysql_fetch_array($result))
  {
  echo "<ul class='venue_box'>";
  if($row['confirmed'] == '') {
  echo "<li><strong>Venue:</strong> " . $row['venue_id'] . "</li>";
}else{
echo "<li><strong>Venue:</strong> <a href=venue/" .  $row['venue_id'] . ">" . $row['venue_id'] . "</a></li>";
}
  echo "<li><strong>Address:</strong> " . $row['address'] . "</li>";
  echo "<li><strong>Type:</strong> " . $row['category_id'] . "</li>";
  echo "<li><strong>Link:</strong> <a  href=index.php?url=" . $row['website'] .  ">website</a></li>";

  echo "</ul>";
  }
mysql_free_result($sql);

I need to replace echo "<li><strong>Venue/strong> " . $row[‘venue_id’] . “</li>”; with if else options above.

copy… and paste. You really can just stick that code inside the other code, though you dont need the open and close <? ?>. You will need to change your SELECT query to pull the confirmed field as well as the others listed there.
(PS: You have a typo in your Else line. Look at the coloring at the end, and figure out where you missed a ". You also missed the semicolon on the endif.)

thank you :slight_smile:
Got to shoot out for a couple of hours will test everything when I get back.

The if else was just a quick example, thanks for pointing out the errors StarLion.
What I can see spence_noodle, just what I’m looking for thanks :cool:

Catch up shortly, thanks again guys :slight_smile:

Well spotted starlion. :slight_smile:


$sql="SELECT venue_id, address, category_id, website, hits,confirmed FROM tbl_venues WHERE venue_id = '".$q."'";

But otherwise, yeah. Thats what I meant.