I am trying to do something in PHP that I thought would be fairly easy
but has become rather troublesome.
I'm trying to retrieve a list of numbers from a MySQL database and
display the contents in a comma delimited string if there is more than
one element. My problem is that the first element of the array is
displaying but not any of the others and I can't figure out why.
$count_lot = 0;
while ($row = mysql_fetch_row($sql_lot_num_result))
{
$lot_num_array[$count_lot] = $row[$count_lot];
echo "<p>\$lot_num_array[$count_lot] is:
$lot_num_array[$count_lot]<br />";
echo "\$count_lot is: $count_lot</p>";
$count_lot++;
}
// if there is more than 1 element in the array then separate them
with a comma and space
if ($count_lot == 1)
{
$lot_num_string = "$lot_num_array[0]";
}
else
{
$lot_num_string = implode(", ", $lot_num_array);
}
echo "<p>\$lot_num_string is: $lot_num_string</p>";
---
The result is:
$lot_num_array[0] is: 0111
$count_lot is: 0
$lot_num_array[1] is:
$count_lot is: 1
$lot_num_array[2] is:
$count_lot is: 2
$lot_num_string is: 0111, ,
---
Why is only the first element displaying but not the rest?
Tony W.
tonyw(no_spam)@liquidationworld.com