Re: A bit of help with a query needed.

From: Date: Tue, 17 Apr 2001 12:08:54 +0000
Subject: Re: A bit of help with a query needed.
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-8615@lists.php.net to get a copy of this message
Hi, which part is not working? Put a "or die(mysql_error())" behind your queries to see which one produces an error. like this: $result = mysql_query("SELECT * FROM ships ORDER BY ship",$db) or die(mysql_error()); > > while ($row = mysql_fetch_array($result)) { > > If ($result) { > $id = $row["id"]; you should put this the other way round that is the if before the while. If($result) will always be "true" within the while-loop. > > While ($result) { you don't need another while here. Leave it out. > $result2 = mysql_query("SELECT * FROM convicts WHERE > convicts.ship = $id ORDER BY convict",$db); put '' around the $id thus: WHERE convicts.ship='$id'...; // you don't neccesarily need the convicts before your columns name. There is no possible ambuguity. > $row2 = mysql_fetch_array($result2) > $id = $row2["id"]; > $convict = $row2["convict"]; > $ref = $row2["ref"]; > $contact = $row2["contact"]; In your original code you don'T do anything with $id, $ref or $contact. I guess that is just left out ;-) Keep on asking. Cheers Johannes

« previous php.db (#8615) next »