Jump to content


This topic is now archived and is closed to further replies.


noob in need of some help

Recommended Posts

Hello, I\'m a noob in need of some help. I currently have a page displaying all contents of a mysql table. There are 5 fields in the table. Name, Games Played, Points, Interceptions and Sacks. Works great.


I want to create a drop down menu with options- name, points, interceptions and sacks. And when the option is selected from the menu, then the data is listed by that option is descending order. I\'m assuming I use the get function but not sure.


Currently the table displays by name in descending order, but I want for example, if you select points from the menu, that the table is requeried to list the data by points in descending order and so on. Hope this makes sense. Any advise is appreciated. Please make it easy to understand. Thanks in advance.

Share this post

Link to post
Share on other sites

Add a form with the dropdown in it.


<form name="form1" method="get" action="<?=$_SERVER[PHP_SELF]?>" >

<SELECT name="orderby">

<OPTION Value="Name">Name</OPTION>

<OPTION Value="Games Played">Games Played</OPTION>

<OPTION Value="Points">Points</OPTION>

<OPTION Value="Interceptions ">Interceptions </OPTION>

<OPTION Value="Sacks">Sacks</OPTION>


<INPUT type="submit" value="Sort">


Get the selected value, defaulting to name if no selection



$orderby = isset($_GET[\'orderby\']) ? $_GET[\'orderby\'] : \'Name\' ;


Set up your query


$query = \"SELECT Name, `Games Played`, Points, Interceptions , Sacks

FROM tablename ORDER BY `$orderby` DESC \";


Process results as now.



Share this post

Link to post
Share on other sites


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.