Forum Moderators: coopster

Message Too Old, No Replies

Help with Dropdown in PHP

Dropdown Listing

         

Basavaraj

5:44 am on Jul 17, 2007 (gmt 0)

10+ Year Member



Hi,

How can I list the the entries of the dropdown box (which are all populated) according to the time they are populated

Basavaraj

6:19 am on Jul 17, 2007 (gmt 0)

10+ Year Member



Hi,

Sorry,this si by using PHP not perl

rocknbil

9:40 pm on Jul 17, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In either case, the logic is still the same, add "desc" to the select command if you want the latest first:

$selectList = '<select name="some_list" id="some_list">';

Then read the records:

$select = "select id,title from table order by date_added";
while (($id,$title) = $sth->fetchrow_array) {
$selectList .= "<option value=\"$id\"">$title<\/option>\n";
}
$sth->finish;

$selectList .= "<\/select">\n";

DrDoc

11:11 pm on Jul 17, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to WebmasterWorld! [WebmasterWorld.com]

The way I read the post, I don't think that's what's being asked ...
So, correct me if I'm wrong, but it appears that you are asking how to get a list of options returned in the same order they were selected. If that's what you're asking (list the entries of [a] dropdown box ... according to the time they are populated), it can't be done very easily. You would need to monitor the selection using JavaScript, and then either write a custom list or something similar to a hidden field, or set a cookie which can then be read server side.

Perhaps if you better clarify what exactly it is that you're asking.

Basavaraj

3:29 am on Jul 18, 2007 (gmt 0)

10+ Year Member



Hi,

My problem is that there are some entries in the dropdown box which i will be getting everyday from the database.I want to sort these elements like latest is first(or last) and oldest is last(or first).
Please clarify me about this issue

DrDoc

5:23 am on Jul 18, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Then, ignore what I said, 'cause I was way off :)

rocknbill is right on the money.