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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

rjgonzaleCommented:
<?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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.