kuldeep Posted November 23, 2009 Share Posted November 23, 2009 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 More sharing options...
onlyican Posted November 23, 2009 Share Posted November 23, 2009 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"]; Link to comment https://forums.phpfreaks.com/topic/182621-showing-selected-item-at-top-of-list/#findComment-963860 Share on other sites More sharing options...
kuldeep Posted November 23, 2009 Author Share Posted November 23, 2009 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 Link to comment https://forums.phpfreaks.com/topic/182621-showing-selected-item-at-top-of-list/#findComment-963866 Share on other sites More sharing options...
onlyican Posted November 23, 2009 Share Posted November 23, 2009 before your loop echo the selected name Then within your while loop, if($strSelectedName != $list->name){ echo $list->name; }//No else as we do not want to show as it is displayed at the top Link to comment https://forums.phpfreaks.com/topic/182621-showing-selected-item-at-top-of-list/#findComment-963869 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.