SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Addict
    Join Date
    Aug 2009
    Posts
    299
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Select menu based on Query COUNT

    Hi Chaps,

    I have a Query that loops through a database, showing all JobID's that have been assigned to a certain user.
    A user can have an unlimited number of JobID's assigned to them.
    What I want to do is use a Select input to assign a job priority, using number 1 to 'COUNT' (number of JobID's for certain user):
    eg.
    HTML Code:
    User A (5 JobID's)
    Select Options:
    1
    2
    3
    4
    5

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,510
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    And your question is?

  3. #3
    SitePoint Addict
    Join Date
    Aug 2009
    Posts
    299
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How do i populate the Select Options with numbers 1 - to - 'COUNT'?

  4. #4
    SitePoint Guru
    Join Date
    Oct 2006
    Location
    Queensland, Australia
    Posts
    852
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here's one of many ways this can be done...

    PHP Code:
    $count 5;

    echo 
    '<select name="job_id">';
    for(
    $i 1$i <= 5$i++)
    {
        echo 
    '<option value="'.$i.'">'.$i.'</option>';
    }
    echo 
    '</select>'
    Or, alternatively, you can be the coolest kid on the street by doing this...

    PHP Code:
    $count 5;

    echo 
    '<select name="job_id">';
    while( 
    $count == true && print('<option value="'.$count.'">'.$count--.'</option>') );
    echo 
    '</select>'

  5. #5

  6. #6
    SitePoint Addict
    Join Date
    Aug 2009
    Posts
    299
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Top stuff, thanks guys!


Bookmarks

Posting Permissions

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