I have a table containing information about books in my library and this table has the following columns: id, title, category. What I want to do is to make a form that will allow me to sort these books according to one of these fields, its just like in you tube when you want to sort videos by date added, relevance, view count etc..
Both the form and the php code are in "view_books.php"
Here is my form:
Code: <form method="POST" action="view_books.php">
Sort by:
<select size="1" name="sort">
<option> id </option>
<option> category </option>
<option> Date Added </option>
</select>
<input type="submit" value="Go!">
</form>
Here is my php code to sort the books in a table:
Code: $query = mysql_query ("SELECT * FROM books ORDER BY id asc ") or die (mysql_error());
?>
<table width="76%" border="0" align="center" >
<?
while($rows = mysql_fetch_array( $query ))
{
?>
<tr>
<td> <font color="#696969" size=2> <?php echo $rows['id']; ?> </font></td>
<td> <font color="#696969" size=2> <?php echo $rows['title']; ?> </font></td>
<td> <font color="#696969" size=2> <?php echo $rows['category']; ?> </font></td>
</tr>
<?
}
?>
</table>
Please apply the changes in my code so that it can perform the required function.
Thanks, any help would be appreciated.
Multidimensional array problems in $_POST
I'm having trouble with a three-dimensional $_POST array. It starts as a two-dimensional array on this side:Code: <html> <head>
Is there something wrong?
Hi all,Just a quick question... can someone look at this code and see if something is wrong?Code: $j = 1;$vals = array();$feedline = array();foreach(explode($delimiter,$b) as $key => $values)
Convert array to string and write to csv file
I am looking to write a MySQL query to a csv file.At the minute I:check for the original file, and delete it;create a new (blank) file;run the MySQL query and pass it into an array;write it to the new
Mail functionality from localhost to server
Hi I am facing problem of mail functionality.When i tested mail functionality in my localhost it works fine but when i tried it on server it didn't work and also no error it displays.So please give me
Mail sending is slow on server
Why mail is taking time to be send on apache-linux server
Rounding a number queried from a database
I know that to display a rounded number you just do echo "round($number)";. But how would I convert the $number varible into a rounded number, so that when I say echo "$number";
PHP Code reffering to database, doing something wrong.. pls help
Well i am quite new with PHP and for school we have to make a PHP script which reffers to a Database,Well, more explicit, we have this form showing all "employees"last name etc. made it week
Pagination
Hi All,I think I'm finally getting somewhere with pagination!I can now submit a query and get the correct number of records back with the correct number of pages. My only problem is, when I press the
using variables in another page
I have a test database set up on localhost. I have a form that I can type a name into, hit the button and it puts the name into the database and into a list on my page. it works fine. Now, I wanted to
Need help adding a timestamp to my filename/variable
Hello, I'm kind of stupid when it comes to php and I need a tiny bit of help. I've got a form/php setup that allows a user to upload an image to my server. The upload is working well, and the code