Jump to content

Showing selected item at top of list


kuldeep

Recommended Posts

Hi,

 

I've got a list of names which i am fetching from database like this:

$qry = db_query("SELECT * FROM names");

 

       

 

        $i=1;     

 

        //prepair list

 

        $html .= '<ul><li>'; 

 

        while($list = db_fetch_object($qry)){ 

 

       

 

        $html .= '<a>'.$list->name.'</a><div style="height:0px;"></div>';

 

          if($i%6==0){

 

                 

 

                $html .='</li><li>'; 

 

                }

 

              $i++;   

 

            } 

 

        $html .='</li></ul>'; 

 

        return $html;

Clicking on a name displays its details on next page.

Now my requirement is that i want to display the selected record on next page at the top of the list and rest coming after this record.

 

I am not getting a way to achieve this!

 

Please suggest me someway of doing this!

Thanks,

Kul.

Link to comment
https://forums.phpfreaks.com/topic/182621-showing-selected-item-at-top-of-list/
Share on other sites

I am slightly confused what you want to achieve here.

You want to echo a list of names.

WHen clicking on the name, it takes them to a new page with the name they clicked on at the top of that page

 

How about making your names a proper link

$html .= "<a href='NewPage.php?name=".$list->name.">".$list->name."</a>.......

 

Then your new page

 

$strSeleName = $_GET["name"];

okey, suppose here's a list of names:

 

Alax

Janie

Tim

Paine

Mauris

 

Coming by while loop.

 

Now suppose a user clicks at Paine, Now the list should be:

 

Paine

Alax

Janie

Tim

Mauris

 

And yes its a proper link, as you suggested and i get name id on details page.

 

Thanks,

Kul

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.