Following on from a question I asked earlier (which was very helpfully answered - thanks) I have a follow on question.
I managed to put a form into my page which successfully linked to another page with filtered results. I then added another form directly below (as a second search filter) but the second one is not working. The code is:
<p style="margin-left:20px;">Search by:<br />
<form action="ordersfiltered.php" method="post">
order_no: <input type="int" name="order_no" />
<input type="Submit" />
</form>
<form action="ordersfiltered_name.php" method="post">
name: <input type="text" name="name" />
<input type="Submit" />
</form></p>
Like I say, if I enter an order_no into the first box and click 'Submit' then I do get to another page with the result filtered accordingly. But when if I enter a name into the second box, the page I get has all the table headings etc but no results. For reference, the relevant code I have on the "ordersfiltered.php" page is:
$result = mysql_query("SELECT * FROM orders WHERE order_no = " . $_POST["order_no"]);
(NB I realise that I should not use SELECT * - its on my list of things to change). This works fine.
The code I have on "ordersfiltered_name.php" is:
$result = mysql_query("SELECT * FROM orders WHERE name = " . $_POST["name"]);
Any ideas why the first one works but not the second?
Also - I would if possible like to amend it add something like WHERE name LIKE '%...%' in case the user doesn't type the whole thing.
Thanks again.
mysql_*functions. They're being deprecated. Instead use PDO (supported as of PHP 5.1) or mysqli (supported as of PHP 4.1). If you're not sure which one to use, read this article.