Jump to content

Code not working?


Chris Ginet

Recommended Posts

You would probably do something like this if you are working with a database

<?php
//Connect to Database
$query = "Select * from TABLE"; // I don't know how many flights you have/want to change. This will do all of them. You might want to include a WHERE in the query to select only a specific flight
$result = mysql_query($query) or die(mysql_error()); //Run query
while($row = mysql_fetch_array($result)) //Loop through results
{
       if($row['OK'] == 1) //If OK is equal to one...
       {
              echo "In Flight";
       } else {
              echo $ARRIVEE;
       }
}

Link to comment
https://forums.phpfreaks.com/topic/41030-code-not-working/#findComment-198690
Share on other sites

if ($OK=1) is always true as it is true you have just assigned the value of 1 to the variable OK. Maybe you want ($OK == 1)

 

$query2 = "IF ($OK==1) echo 'In Flight'; else  echo ARRIVE ='$ARRIVEE'";

 

$result2 = mysql_query($query2);

 

but even then $query2 doesn't look like any mysql query I've ever seen.

 

 

Link to comment
https://forums.phpfreaks.com/topic/41030-code-not-working/#findComment-198693
Share on other sites

Hello Chris,

Haven't seen you in a while. Anywho onto the coding:

 

You need to add in table code to the echo so:

while($row = mysql_fetch_array($result)) //Loop through results
{
       if($row['OK'] == 1) //If OK is equal to one...
       {
              $row .= "<tr><td>In Flight</td></tr>";
       } else {
              $row .= '<tr><td>'.$ARRIVEE.'</td></tr>';
       }
}

echo '<table>'.$row.'</table>';

 

Mike

Link to comment
https://forums.phpfreaks.com/topic/41030-code-not-working/#findComment-198805
Share on other sites

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.