RE: [PHP-DB] A bit of help with a query needed.

From: Date: Tue, 17 Apr 2001 14:59:37 +0000
Subject: RE: [PHP-DB] A bit of help with a query needed.
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-8622@lists.php.net to get a copy of this message
Thanks for that. I've cleaned up things a bit for the time being. I'm still getting an error though. Parse error: parse error in c:\usr\local\www\pages/ships.php on line 30 Line 30 turns out to be $convict = $row["convict"]; so I'm assuming that it's having trouble with the array. I've tried changing $row to $row2 to no avail. That also why I had the rest of the convicts fields in the first place (but didn't display then). When I originally played with this I used a Left Join between the two tables and it all worked accept only one convict was returned for each ship and ship's were listed more than once if there were more than one convict on the ship (of course). Anyway here is the cleaned up code. <?php $db = mysql_connect("localhost", "root"); mysql_select_db("convicts",$db); $result = mysql_query("SELECT * FROM ships ORDER BY ship",$db) or die(mysql_error()); If ($result) { while ($row = mysql_fetch_array($result)) { $id = $row["id"]; $ship = $row["ship"]; $voyage = $row["voyage"]; $sex = $row["sex"]; $year = $row["year"]; echo "<font size=\"3\"><b>$ship</b></font><br> <font size=\"2\">$voyage</font><br> <font size=\"2\">$sex</font><br> <font size=\"2\">$year</font><p>\n"; $result2 = mysql_query("SELECT * FROM convicts WHERE ship = '$id' ORDER BY convict",$db); $row = mysql_fetch_array($result2) $convict = $row["convict"]; echo "<font size=\"3\">$convict</font><br>\n"; } } Else { echo "<font color=\"#FF0000\"><b>Sorry no records for that letter</b></font>\n"; } } ?>

« previous php.db (#8622) next »