I am stuck with this, I have been putting myself through a crash course in PHP all week making a fake amazon like site! I want to order my table using a drop down menu but cant work out how! I know the SQL thats the easy bit but the way I have tried to do it is follows:
Set up variables for example
$query = "SELECT bookname, bookauthor, bookpub, bookisbn
FROM booktable
ORDER BY bookname ASC";
$query2 = "SELECT bookname, bookauthor, bookpub, bookisbn
FROM booktable
ORDER BY bookauthor ASC";
Then I have my form=
<form name="sort" action="products.php" method="post">
<select name="order">
<option value="choose">Make A Selection</option>
<option value="title">Title</option>
<option value="author">Author</option>
<option value="publisher">Publisher</option>
<option value="isbn">Book ISBN-10</option>
</select>
<input type="submit" value=" - Sort - " />
</form>
Now for the bit I cant do,
I set up the variable:
$sort = $_POST['order'];
so that whatever the value of the dropdown menu is, will become assigned to the variable $sort..... (is that right?)
then I want to say IF the value of $sort is the same as lets say 'author' than $query = $query2 but I dont know how to say it without huge error courtesy of XAMPP!
I hope this all makes sense and that my method to try and achieve it is close to correct
Thank you