Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

results showing all but one result 1

Status
Not open for further replies.

Aeros

Programmer
Oct 7, 2002
166
US
Im displaying the results of a query into a drop down form. I get all of the results except for the last record:

Query:
mysql_select_db($database_aaa, $aaa);
$query_ColorResults = "SELECT J.intColorID, C.varColor FROM ProductColor_JUNC J JOIN Color C ON J.intColorID = C.intColorID WHERE J.intProdID = '$PID' ORDER BY C.varColor";
$ColorResults = mysql_query($query_ColorResults, $aaa) or die(mysql_error());
$row_ColorResults = mysql_fetch_assoc($ColorResults);
$totalRows_ColorResults = mysql_num_rows($ColorResults);


Heres is my php code:

<select name="colorID">
<?php
while(list($intColorID,$varColor) = mysql_fetch_row($ColorResults)){
echo "<option value=$intColorID>$varColor</option>\n";
}
?>
</select>

Im sure its something simple im overlooking...thanks
 
try printing $intColorID and $varColor after the loop terminates, you may have to declare them outside. Also, why are you doing the mysql_fetch_array? Get rid of all extraneous code and see if it is still busted.
 
Thanks for the feedback...im not useing mysql_fetch_array though.

I tried printing that out side of the loop and still no go
 
My bad, I meant mysql_fetch_assoc(). Why are you doing that before your loop? Get rid of all that extra code under "Query:", it will help isolate the problem.
 
And what do you mean, "still no go"? Do you get a duplicate of the last row printed or nothing at all?
 
Ah that did it. I was getting all records except for the last one. By taking out the following lines this fixed the problem:

$row_ColorResults = mysql_fetch_assoc($ColorResults);
$totalRows_ColorResults = mysql_num_rows($ColorResults);

Im still new to php so im still figuring this stuff out. Im traditionally a ColdFusion programmer so this is still new.

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top