Order By variable.
Posted on 2009-05-14
im in dire need of some expert assistance. i've got a table populated with the data from a mysql database. i want to be be able to sort the data either by ID, name, or whatever else i chose.
here's the code i am using
<form name='dd' action='repdetailstable.php' method='POST'>
<select name="sort1" ID="sort1" onChange='this.form.submit()'>
<option selected value='statVal_id'>Sort By</option>
<option value='repNumber'>Rep #</option></select>
$selectQuery = "SELECT * from repDetails
ORDER BY $sort1 ";
but whenever i initially run the script i get an error:
"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 3"
but as the rest of the page appears, i can use my drop down and when i choose an option, the data appears as it should.
can anyone help me? i would like it so that when the page loads, it appears in order of ID (statval_id)