Jump to content

Select Order


Doyley

Recommended Posts

Ok, this is the table

 

  id  rulesdesc 

      1 House Rules (Ask Licensee)

      2 Old EPA

      3 BAPTO

      4 World Rules

      5 Blackball

      6 Official Pub Pool Rules

      7 Other

 

Earlier on in the PHP script I have pulled out the ID from another table that relates to the id from this table.  I want to make a drop down field with the ID I have pulled out selected and the rest of the results.

 

I can do this pretty easily with 2 sql queries but I was wondering if there was a more efficient way to do this.

Link to comment
https://forums.phpfreaks.com/topic/50792-select-order/#findComment-249749
Share on other sites

Hmm I don't think so.

 

This is the code I am currently using.  It works but I think there is a better way to do it.  $rules is a number which relates to the id column from the table I posted above.

 

$selectsql="select rulesdesc from rules where id='$rules'";
$selectnew=mysql_query($selectsql) or die(mysql_error());
$sel=mysql_fetch_array($selectnew);

$select2sql="select id,rulesdesc from rules where id!='$rules'";
$select2new=mysql_query($select2sql) or die(mysql_error());

echo "<tr>\n";
echo "<td><b>Rules</b></td>\n";
echo "<td>\n";
echo "<select name=\"rules\">\n";
echo "<option value=\"$rules\">$sel[0]</option>\n";

while($sel2=mysql_fetch_array($select2new)){

echo "<option value=\"$sel2[0]\">$sel2[1]</option>\n";
}

echo "</select>\n";
echo "</td>\n";
echo "</tr>\n";

Link to comment
https://forums.phpfreaks.com/topic/50792-select-order/#findComment-250531
Share on other sites

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.