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.
Pulling out some result data from MYSQL
Hey Guys, I've built a PHP page that has a for just imagine something like registration form, So obviously it posts data into my table in my DB, So Now what I’m trying to do is creating a form
Selecting an "empty" date formated field
How do you select an "empty" date field? I've tried the few ways I can think.
If statement help please.
Hello on my site I have 2 content boxes. 1 is for the main content (which is the biggest one) and the second one is for a sub navigation (which is a small box). I am trying to write an IF statement so
my two tables
table1 : col1 = topicid , col2 = topictable2 : col1 = sentid, col2 = sentenceCode: require_once("includes/connection.php"); $trends = mysql_query("SELECT topicid, topic FROM
small inaccuracies
I have this code to convert fractional base 10 into base 2: while($num > 0) { echo "<tr><td>". $num." * 2 =
Retrieving innerHTML with cURL?
Hey all (sorry I know I'm a leecher, but I soon won't be. This is my first PHP project, but not my last ).I need help with a little problem I am having. I am using cURL to navigate through some pages
pass form variables straight to email, no database required?
hello all,im working on this form...http://www.adobedayevents.com/project_request/project_request.phpWhat we want to use this form for, is for our client Adobe, to have there field marketing managers
Shuffle Array
Hi,I am writing a script for a game that needs players to randomly be assigned a target (another player) in a loop so that each player is matched with someone other than who has them. See below:Andy
Dynamic Data + Sql Server 2005 Enterprise?
Hi! I have just started to learn ASP.NET, and it looks like it is quite a lot to learn. Im not really sure where I should begin, but I have watched the Dynamic Data
background color imagefill
HelloI would like to ask you why I see this square in red color just in my local xampp installation. If I run the code in the remote server (http://www.arreglaordenador.com/numberimage2.php) I see the