Ask a Question related to PHP Development, Design and Development.
-
Tony W. #1
simple php question: mysql_fetch_row display array contents
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
Tony W. Guest
-
simple question about passing array to document
Hi.I have a question I was hoping someone could help me with. I have created a simple page - page1.mxml. In that page I have an unnamed... -
Simple Display Question
Hello all- This query works below, but it displays only one record at a time. It displays a random image each time. How can I make it display two... -
Simple go to frame (contents of field) script
Hi, I'm having a problem with one of my scripts and I can't figure it out. I have it set so that the I have a object on stage that, when... -
simple array question?
On 12-Aug-2003, "Randell D." <you.can.email.me.at.randelld@yahoo.com> wrote: http://www.php.net/manual/en/function.list.php -- Tom... -
Simple Array question
Hi, If i am posting something like this from a form: <input type=checkbox name='id' value=3> <input type=checkbox name='id' value=4> How do i... -
Jeffrey Silverman #2
Re: simple php question: mysql_fetch_row display array contents
On Mon, 18 Aug 2003 09:44:31 -0700, Tony W. wrote:
<snip!>> I am trying to do something in PHP that I thought would be fairly easy but
> has become rather troublesome.
There are a bunch of potential problems with your code, but I am too beat
right now to clarify. Sorry. I probably shouldn't even have responded at
all. I know I would find it annoying if someone responded to *me* with
this sort of answer...
i'll post a real answer later...
--
Jeffrey D. Silverman | jeffrey AT jhu DOT edu
Johns Hopkins University | Baltimore, MD
Website | [url]http://www.wse.jhu.edu/newtnotes/[/url]
Jeffrey Silverman Guest
-
Tom Thackrey #3
Re: simple php question: mysql_fetch_row display array contents
On 18-Aug-2003, [email]tonyw@liquidationworld.com[/email] (Tony W.) wrote:
The index to $row should be the column name or index, but not $count_lot> 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];
(snip)> echo "<p>\$lot_num_array[$count_lot] is:
> $lot_num_array[$count_lot]<br />";
> echo "\$count_lot is: $count_lot</p>";
>
> $count_lot++;
> }
>
--
Tom Thackrey
[url]www.creative-light.com[/url]
Tom Thackrey Guest



Reply With Quote

