I'd like to use the post variable value in my sql query to sort data in order chosen by a user. The table gets displayed correctly with appropriate fields but the values are not sorted.
I'm aware this is subject to sql injection, however, I'm doing this for training purposes on my local server.
<?php
$sort_in = $_POST['SortIn'];
$sql = 'select * from db.Runner order by "'.$_POST['SortIn'].'"';
$result = mysql_query($sql, $con);
if($result)
{
echo "<table border = '1'>
<tr>
<th>RunnerID</th>
<th>EventID</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr><td>";
echo $row['RunnerID'];
echo "</td><td>";
echo $row['EventID'];
echo "</td><td>";
</tr>";
}
echo "</table>";
?>