?

Search Help Board

PHP FAQ
PHP Articles
PHP Help
Bulletin Board

PHP Manual (NEW!)
First Time PHP'ers
Help with programming
Sql assignment help
PHP Homework Help


C# Help

?
?array from table - skipping first item
Author:??(---.nyc.rr.com)
Date:???05-03-04 10:06

I am trying to take some information from a table, and place the information into an array (so I can easily access elements in the table, without having to do a query everytime). However, when I perform the query and try to place the elements into an array, the first row of my table is skipped.

Here is the code:

// Get COLOR information
$colorhtml = array();
$colorname = array();
$thaquery = "SELECT * FROM color";
$total_result = mysql_query($thaquery,$db);
if (mysql_fetch_array($total_result))
{
while ($listinfo = mysql_fetch_array($total_result))
{
$thecolorid = $listinfo["colorid"];
// enter color html
$colorhtml["$thecolorid"]=$listinfo["colorhtml"];
// enter color name
$colorname["$thecolorid"]=$listinfo["colorname"];
// Test element
echo $colorname["$thecolorid"].": ".$colorhtml["$thecolorid"]."
";
}
}
?>

Here is what the result is:

red: FF0000
orange: FF6600
yellow: FFCC33
green: 006600

Here is what I need (you'll see that the first row "blue" is skipped):

blue: 000099
red: FF0000
orange: FF6600
yellow: FFCC33
green: 006600


Thanks for any help you can give....

?Re: array from table - skipping first item
Author:??(---.scpe.powergate.ca)
Date:???05-04-04 09:25


try

if ($total_result)
{
while ($listinfo = mysql_fetch_array($total_result))
{

Go to Top??|??Go to Topic??|??Threaded View??|??Search?
??|??
New Topic
?Reply To This Message
?Your Name:
?Your Email:
?Subject:
Email replies to this thread, to the address above.
??

Provided By
Phorum