Page 1 of 1

Send list item to top

Posted: Tue Apr 13, 2010 7:50 am
by thirteen
I have the following PHP Code which queries a database and generates a list of 4 items.

Code: Select all

echo'<a href="index.php?id='.$id.'&p='.$row["id"].'"><li style="width:207px; background-color:#bcbec0; color:#ffffff; border:0px; font-weight:bold;" class="mainli">'.$row["pagetitle"].'</li></a>';
					$sql2 = "Select * from $table where parent = $row[id] and published = 1 order by menuindex asc";
It works fine and as needed. What I need now is that when I click on a certain item, it moves to the top of the list and the rest remain as they are.

For example it generates:

Nokia
Samsung
Siemens
Motorola

When I lick on Siemens, the list is displayed as follows:

Siemens
Nokia
Samsung
Motorola

Re: Send list item to top

Posted: Tue Apr 13, 2010 9:35 am
by omniuni
Unless you want to add javascript, make each item a link to the same page but including movetotop=32 where the number is the ID of your entry in the DB. Fetch the entry, display it at the top, and then remove it from the rest of the results.

Re: Send list item to top

Posted: Tue Apr 13, 2010 9:54 am
by thirteen
Can you show demo example or code please?