Jump to content

[SOLVED] "Select all" Option dropdown


carefree

Recommended Posts

Heres a challenge:

 

Im trying to create a "Select all" search Option dropdown form , but the options are stored the the database.

 

Heres my original form:

 

<option value="<? echo $rst["id"]; ?>"><? echo $rst["cat_name"]; ?></option>

 

Basicly it has 20 or so options,  but no "search all" option.

 

I had a play and came up with this but its adding the "select all" option every 2nd field:

 

<option value="<? echo $rst["id=all"]; ?>">All Categories</option>

<option value="<? echo $rst["id"]; ?>"><? echo $rst["cat_name"]; ?></option>

 

Can anyone help?

Link to comment
Share on other sites

can i see the full coding you have now?

 

Here it is:)

 

<form name="form2" method="post" action="showcategory.php">

              <table width="100%" border="0" cellspacing="0" cellpadding="2">

                <tr>

                  <td width="17%"><FONT color=#000000><strong><font color="#000000" size="2" >SEARCH</font></strong></FONT></td>

                  <td width="31%"><input type="text" name="keyword"></td>

                  <td width="24%"><select name="cid">

                      <?

  $cats=mysql_query("select * from sbwmd_categories where pid=0");

  while($rst=mysql_fetch_array($cats))

  {

    ?>

    <option value="<? echo $rst["id=all"]; ?>">All Categories</option>

                      <option value="<? echo $rst["id"]; ?>"><? echo $rst["cat_name"]; ?></option>

                      <?

}//end while

?>

                    </select></td>

                  <td width="28%"><input type="submit" name="Submit2" value="Go" class="input"></td>

                </tr>

              </table>

            </form>

Link to comment
Share on other sites

next time please use the bbcode Code tag please its the # button when you post :D

 

<form name="form2" method="post" action="showcategory.php">
              <table width="100%" border="0" cellspacing="0" cellpadding="2">
                <tr>
                  <td width="17%"><FONT color=#000000><strong><font color="#000000" size="2" >SEARCH</font></strong></FONT></td>
                  <td width="31%"><input type="text" name="keyword"></td>
                  <td width="24%"><select name="cid"><option value="all">All Categories</option>
                      <?
           $cats=mysql_query("select * from sbwmd_categories where pid=0");
           while($rst=mysql_fetch_array($cats))
           {
                   ?>
                      <option value="<? echo $rst["id"]; ?>"><? echo $rst["cat_name"]; ?></option>
                      <?
               }//end while
                ?>
                    </select></td>
                  <td width="28%"><input type="submit" name="Submit2" value="Go" class="input"></td>
                </tr>
              </table>
            </form>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.