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
https://forums.phpfreaks.com/topic/59039-solved-select-all-option-dropdown/
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>

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>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.