crmamx Posted January 31, 2011 Share Posted January 31, 2011 I am reading the table passwords to see if the password exists. If true then read the table airplanes and output a table with the data. If the password is not in the table, then output msg AMA Number Not Found. All of this works. My problem is if it does not find the password, it echos the msg, but it also echos the talble headers. I would like to goto end, skip the echo of the table if it does not find the password. Just can't figure out how to do it. <html> <head> </head> <body> <?php // Connect to database===================================================== include("connect_db.php"); $table1='passwords'; $table2='airplanes'; // Retrieve form data ====================================================== $amano = $_POST['amano']; // Send password query =========================================================== $result = mysql_query("SELECT * FROM $table1 WHERE ama='$amano'") or die(mysql_error()); if (!$result) { die("Query to show fields from table failed"); } // Check if AMA number found in password file ============================= $num=mysql_numrows($result); if ($num==0) { echo "AMA Number Not Found"; } else { echo "Record Found"; } // Send airplanes query =========================================== $result = mysql_query("SELECT * FROM $table2 WHERE ama='$amano'") or die(mysql_error()); if (!$result) { die("Query to show fields from table failed"); } echo "<table border='10' cellpadding='3' cellspacing='2'>"; echo "<p>Airplanes for Joe Blow</p><br>"; echo "<tr> <th>ID</th> <th>AMA #</th> <th>Model Name</th> <th>Model MFG</th><th>Wingspan</th><th>Engine</th><th>Decibels</th></tr>"; // keeps getting the next row until there are no more to get ================ while($row = mysql_fetch_array( $result )) { // Print out the contents of each row into a table ========================== echo "<tr><td>"; echo $row['id']; echo "</td><td>"; echo $row['ama']; echo "</td><td>"; echo $row['model_name']; echo "</td><td>"; echo $row['model_mfg']; echo "</td><td>"; echo $row['wingspan']; echo "</td><td>"; echo $row['engine']; echo "</td><td>"; echo $row['decibels']; echo "</td></tr>"; } echo "</table>"; ?> <br> Put something here. <body> </html> Thanks, Curtis Quote Link to comment https://forums.phpfreaks.com/topic/226274-sure-wish-php-had-a-goto-statement/ Share on other sites More sharing options...
trq Posted January 31, 2011 Share Posted January 31, 2011 It does. http://au.php.net/goto Ive never even thought about using it though. Quote Link to comment https://forums.phpfreaks.com/topic/226274-sure-wish-php-had-a-goto-statement/#findComment-1168022 Share on other sites More sharing options...
AbraCadaver Posted January 31, 2011 Share Posted January 31, 2011 Why would you need a goto? There are lots of ways to do it, but just put the table and loop code inside the if ($num==0) block. Quote Link to comment https://forums.phpfreaks.com/topic/226274-sure-wish-php-had-a-goto-statement/#findComment-1168030 Share on other sites More sharing options...
nankoweap Posted January 31, 2011 Share Posted January 31, 2011 It does. http://au.php.net/goto Ive never even thought about using it though. wow! i didn't know that. sure wish they'd deprecate it and people wouldn't use it. Quote Link to comment https://forums.phpfreaks.com/topic/226274-sure-wish-php-had-a-goto-statement/#findComment-1168045 Share on other sites More sharing options...
PFMaBiSmAd Posted January 31, 2011 Share Posted January 31, 2011 Actually, php.net just added it in php5.3 so that php help forums like this one will get more traffic Quote Link to comment https://forums.phpfreaks.com/topic/226274-sure-wish-php-had-a-goto-statement/#findComment-1168056 Share on other sites More sharing options...
Maq Posted January 31, 2011 Share Posted January 31, 2011 Beware: when using goto, you greatly increase your chance of being attacked by a velociraptor. Quote Link to comment https://forums.phpfreaks.com/topic/226274-sure-wish-php-had-a-goto-statement/#findComment-1168058 Share on other sites More sharing options...
nankoweap Posted January 31, 2011 Share Posted January 31, 2011 Actually, php.net just added it in php5.3 so that php help forums like this one will get more traffic that's disturbing. oh well, in the long run it will mean more work for geeks like me that make a decent living fixing the mistakes of others. Quote Link to comment https://forums.phpfreaks.com/topic/226274-sure-wish-php-had-a-goto-statement/#findComment-1168074 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.