SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Guru
    Join Date
    Feb 2006
    Location
    Chepstow, South Wales
    Posts
    907
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    need to create a no value select option in dynamic drop down.

    I've created that a drop down that shows the selected value for editing but allows for selection if adding to the database.

    Im trying to add an option in there with a value of nothing, if something inthe drop down isnt selected.

    Hope you know what I mean.

    Here is my code:

    PHP Code:
    <select name="pcats" size="1">
    <?php $qw=mysql_query("select cat_Id, category_Name from category order by category_Name ASC") or die (mysql_error());
    while(
    $r=mysql_fetch_assoc($qw))
        { 
    if(
    $r['cat_Id']==$pcats)
        {
    echo 
    "<option value='$r[cat_Id]' selected>$r[category_Name]</option>";
        }
    else
        {
    echo 
    "<option value='$r[cat_Id]'>$r[category_Name]</option>";
        }

    ?>
    </select>
    The empty option need to go in the second echo.

  2. #2
    SitePoint Guru
    Join Date
    Feb 2006
    Location
    Chepstow, South Wales
    Posts
    907
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok got it sorry


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
  •