How to submit a form to the same page?
Posted on
16th Feb 2014 07:03 pm by
admin
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.
No comments posted yet
Your Answer:
Login to answer
239
52
Other forums
php email checker
I am having alot of trouble finding info on how to do these email things. I need to do the following
Linkage between two scripts
Okay say I have this for a link in a script:
Code: <li><a href="#&q
Convert Binary String to Decimal
Trying to Get:
Decimal: 305419896
Out of:
Binary String: xV4
CE 7.1 and External GIS integration
Hi All,
We want to develop an application on CE 7.1 which uses GIS features from an exter
Refining of search Criteria
Dear Friends
I need a help, I have a search page which of cars related, which has different s
Please Help my PHP Dating Function.
Hi everyone!
Well here is my code that displays this:
It works wonderful.
Will an XHTML DOCTYPE interfere with my PHP if I'm not experienced enough?
I've read this article here: http://friendlybit.com/html/why-xhtml-is-a-bad-idea/
In a nutshe
Unifying logins of two different scripts
I have two different game scripts which I want to embed on my own site. The problem is I don't want
Email/MMS to Site
Hey guys. I'm looking for a way for a user to upload images and/or text via their cell phones. It
Checking if multidimensional array is empty?
I have a for with multiple test input fields. Specifically the user submits multiple names and ages