Two different drop downs from mySQL

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Hi there,

I have a admin area for a website, and on some part the admin can
select options from two different drop down boxes. Now i thought that
it would be better to use one Query for both dropdowns. How can i get
them together?
I now have something similair twice:

<select name="series_id" class="dropdownbox" id="series_id">
  <option value="0">- select -</option>

      $db = mysql_connect("localhost", "name", "pass");
      $result = mysql_query("SELECT * FROM series ORDER BY name");
      if ($data = mysql_fetch_array($result)){
           do {
               $current_id = $data['series_id'];
               if($current_id == $id){$selected = "selected";};
               echo "<option value=\"".$data['series_id']."\"
          } while ($data = mysql_fetch_array($result));
        } else {
            echo "";    

I hope it's clear what i mean. I do not make connection twice, but the
rest is similair except for the tablename of course.

Thanks in advance..

Greetings knoakske

Re: Two different drop downs from mySQL

On 21 Jan 2005 03:32:55 -0800, (knoak) wrote:

Quoted text here. Click to load it

 If it's a different table, it's a different query, so just run two queries.
You should probably factor out the other code into a function though, so you're
not repeating that - i.e. make it take parameters such as the SQL query (or an
array of the data produced from the query), and the column names used for the

< Space: disk usage analysis tool

Site Timeline