Sort by column heading
Posted: Tue Aug 11, 2009 8:57 am
Hi
i am pulling data from the database.
i would like it to appear so that the user can click on the column head on the page and it would sort the data by the selected data head...
here is the code so far... the connection has been made to the database, and at the moment, it only pulls the data up and sorts by hotelname...
any ideas?
i am pulling data from the database.
i would like it to appear so that the user can click on the column head on the page and it would sort the data by the selected data head...
here is the code so far... the connection has been made to the database, and at the moment, it only pulls the data up and sorts by hotelname...
Code: Select all
$result = mysql_query("SELECT * FROM hotelsignup order by hotelname");
echo "<table border='1'>
<tr>
<th>Hotel Name</th>
<th>Address1</th>
<th>Address2</th>
<th>County</th>
<th>Hotel Star</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['hotelname'] . "</td>";
echo "<td>" . $row['address1'] . "</td>";
echo "<td>" . $row['address2'] . "</td>";
echo "<td>" . $row['county'] . "</td>";
echo "<td>" . $row['starrating'] . "</td>";
echo "</tr>";
}
echo "</table>";
sort($row['hotelname']);
mysql_close($con);