Jump to content

Help with simple IF statement


leightr

Recommended Posts

Can someone point out what is wrong with this?

 

{
if ($street == null) {
echo 'No Directions'; }
ELSE {
  echo "<td><a href=directions.php?id=" .$row['id']. ">Map</td>";
  }
  }
  echo "</tr>";

 

It should say No Directions if $street is null. However it doesnt. It just echo's echo "<td><a href=directions.php?id=" .$row['id']. ">Map</td>"; instead.

Link to comment
https://forums.phpfreaks.com/topic/57927-help-with-simple-if-statement/
Share on other sites

Sorry. I forgot to paste the code ...  :o

 

Anyways, when I used isset nothing happened, it just did the same as the first code I pasted.

 

Here is more of the code:

$practice = mysql_query("SELECT * FROM schedules WHERE teamid='$username' AND gametype='Practice'");
echo "<h1>Scheduled Practice Games</h1>";
echo "<table border='1'>
<tr>
<th>Game Type</th>
<th>Game Location</th>
<th>Game Time</th>
<th>Game Date</th>
<th>Op. Team</th>
<th>View Map</th>
</tr>";
while($row = mysql_fetch_array($practice))
  {
  echo "<tr>";
  echo "<td>" . $row['gametype'] . "</td>";
  echo "<td>" . $row['gamelocation'] . "</td>";
  echo "<td>" . $row['gametime'] . "</td>";
  echo "<td>" . $row['gamedate'] . "</td>";
  echo "<td>" . $row['oppositeteam'] . "</td>";

// Lets see if there is a address to show a map link.
$street = $row['street'];
{
if ($street == null) {
echo 'No Directions'; }
ELSE {
  echo "<td><a href=directions.php?id=" .$row['id']. ">Map</td>";
  }
  }
  echo "</tr>";
}
echo "</table>";

I have a question. How would I do this samething but without the database having to say NULL? Basically I want it to check if it is blank and than do the if?

 

 

// Lets see if there is a address to show a map link.

$street = $row['street'];

{

if ($street == "NULL") {

echo "<td>". 'No Directions'. "</td>"; }

ELSE {

  echo "<td><a href=directions.php?id=" .$row['id']. ">Map</td>";

  }

  }

  echo "</tr>";

}

echo "</table>";

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.