View Full Version : A question using while function.

04-02-2007, 05:33 AM
I am creating a listings system for a client. What the site does it you sign in and put your name on a list. Which other people will look at, and give them a call to perform that job. Im still pretty new at PHP and Im kinda stuck at displaying the list once people have put there names on it. I have the form which puts their names in the database but I cant figure out how the while function works. If anyone has any advice they could give me that would help tremendously.

I need it to bring out these items from the database and create a list with it....

1. ID Number (just to keep the list in order)
2. username
3. first name
4. last name
5. phone
6. alternate phone

if anyone could help me out with this it would be greatly appreciated. Like i said I have some of it completed, im just stuck at the while function. Thanks in advance for whoever can help me and also thanks for those who try as well.

04-02-2007, 12:09 PM
This will echo an unformatted list of all your usernames. It's simply a matter of playing with this to retrieve the correct data and format it as you please.

$query = mysql_query("SELECT username FROM tablename");

while ($output = mysql_fetch_array($query)){

echo $output["username"];


04-02-2007, 04:20 PM
While is a pretty basic concept in both programming in PHP. I suggest you pick up a beginner's PHP book. Or a general purpose programming book.

04-02-2007, 07:49 PM
A question using while function.While is not a function at all. Its a Construct