Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Feb 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    A question using while function.

    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.

  • #2
    Senior Coder
    Join Date
    Jul 2005
    Location
    UK
    Posts
    1,051
    Thanks
    6
    Thanked 13 Times in 13 Posts
    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.

    PHP Code:
    $query mysql_query("SELECT username FROM tablename");

    while (
    $output mysql_fetch_array($query)){

     echo 
    $output["username"];



  • #3
    Senior Coder
    Join Date
    Jan 2007
    Posts
    1,648
    Thanks
    1
    Thanked 58 Times in 54 Posts
    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.

  • #4
    New Coder
    Join Date
    Apr 2007
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by pforsbergfan9
    A question using while function.
    While is not a function at all. Its a Construct


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •