Jump to content

Select Order


Doyley

Recommended Posts

Thanks for your reply.

 

No, i'll try to provide an example.

 

uid    item

1      Shoes

2      Socks

3      Gloves

4      Coat

5      Scarf

 

I would like it so it would select item 3 first and then the rest afterwards.

Link to comment
Share on other sites

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