Simple PHP Loop

Trying to teach myself PHP and it's not going as well as I'd hoped.  I've tried several loops, but the same thing keeps happening.  Instead of displaying a loop of 10 items in a list, all I get is the first item.  Here is the code I am using:

<?php


while($x<11)
{
  echo '<li><font size="2">' . $flowers[0]["Name"] . '<br>';
  $x++;

}

I'm trying to display a top ten list.  I also tried a foreach loop.  Obviously, I don't get it.
Thanks in advance.



?>

mcgeorge40Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
rjgonzaleConnect With a Mentor Commented:
<?php
// We should always initialize values, not 100% required but always good
$x = 0;
// the loop go from 0 to 9 (10 items)
while($x<10)
{
// changed to show element $x of the array and not always the element 0
  echo '<li><font size="2">' . $flowers[$x]["Name"] . '<br>';
  $x++;

}
0
 
keithslaterCommented:
<?php


while($x<11)
{
  echo '<li><font size="2">' . $flowers[$x]["Name"] . '<br>';
  $x++;

}
?>
0
 
mcgeorge40Author Commented:
Hi.  It looks like you guys both wrote the same thing.  Thank you!

For some reason however, I am getting only the first item listed on the left hand column, using this code exactly.

http://www.sendflowersinc.com/flowerproduct.php?ProductID=TF24-1

You'll see "perfect white lilies", but none of the remaining ten.  Any ideas?
0
 
mcgeorge40Author Commented:
never mind.  i made a mistake.  Thank you!  Now i understand the loop also.
0
 
mcgeorge40Author Commented:
Thank you.
0
All Courses

From novice to tech pro — start learning today.