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="dropdown box" id="series_id" >
<option value="0">- select -</option>
<?php
$db = mysql_connect(" localhost", "name", "pass");
mysql_select_db ("db_name");
$result = mysql_query("SE LECT * FROM series ORDER BY name");
if ($data = mysql_fetch_arr ay($result)){
do {
$current_id = $data['series_id'];
if($current_id == $id){$selected = "selected"; };
echo "<option value=\"".$data['series_id']."\"
".$selected.">" .ucfirst($data['name'])."</option>\n";
} while ($data = mysql_fetch_arr ay($result));
} else {
echo "";
};
mysql_close($db );?>
</select>
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
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="dropdown box" id="series_id" >
<option value="0">- select -</option>
<?php
$db = mysql_connect(" localhost", "name", "pass");
mysql_select_db ("db_name");
$result = mysql_query("SE LECT * FROM series ORDER BY name");
if ($data = mysql_fetch_arr ay($result)){
do {
$current_id = $data['series_id'];
if($current_id == $id){$selected = "selected"; };
echo "<option value=\"".$data['series_id']."\"
".$selected.">" .ucfirst($data['name'])."</option>\n";
} while ($data = mysql_fetch_arr ay($result));
} else {
echo "";
};
mysql_close($db );?>
</select>
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
Comment