On 3/22/2011 6:22 PM, Jim Giner wrote:
Kinda new to this, but I've been puttering/writing for about 3 weeks now and
have some good working screens up.  Ran into something new while I was
debuggina script today.

Tried to echo the $i value within a for loop as part of the list of items I
was building
Something like

for ($i=0;$i<$rows;$i++)
     echo $i.' '.$row['itemname'];

I expected to see :

1 item1
2 item2

but instead I got

1 item1
f item2

Yes - an 'f' and not a 2.

Tried it some more with this:

for ($i=1;$i<10;$i++)
     echo $i." item".'<br>';

and got

c item
d item
e item
f item
g item
and so on.

It seems that I can only output the value of $i if I output a string in
front of it

echo ' '.$i;

works fine but
echo $i;
does not.

Any ideas?

If off your subject a bit; but, I suggest using
foreach($row as $value)
        echo "$i $value<br />\n";

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to