Hi there,
I am trying to produce a form that POSTs to itself and limits the recordset used to display the page. Here is what is working thus far...
This works great for one submission...then of course the next time the page is submitted the value of $prodSearch is the last entered value.
What I would like is a method of allowing the users to "drill down" into the recordset/s.
Sample Table Data
In my ideal world...the use would be able to type in "Canon" submit, then type in EOS and the recordset would limit down to only the two CANON EOS Products in the example.
So...my SQL would look something like the following.
My question is how can I go about storing the other variable/s and tacking it on to the end of my select...session variables? Hidden fields? Javascript?
As you may tell, I am new to PHP/MYSQL and I would appreciate any ideas on this.
Thanks in advance.
Peter.
Remember- It's nice to be important,
but it's important to be nice
I am trying to produce a form that POSTs to itself and limits the recordset used to display the page. Here is what is working thus far...
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html>
<head>
<title>Product Enquiry Emulator</title>
</head>
<body>
<table width="50%" border="1">
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<tr>
<td>Product Search:</td>
<td></td>
</tr>
<tr>
<td><label>Search
<input type="text" name="prodSearch" id="prodSearch" />
</label></td>
<td>
<input type="submit" name="submit" id="submit" value="Submit" />
</td>
</tr>
</form>
</table>
<?php
// This page will be a product search emulator.
include('conn/connect.php');
include('conn/database.class.php');
if (isset($_POST['prodSearch'])){
$prodSearch = $_POST['prodSearch'];
}
// My Conntection values.
$db = new Database($config['server'], $config['user'], $config['pass'], $config['database'], $config['tablePrefix']);
// connect to the server
$db->connect();
$sql = "select * from d3_import WHERE rsv_desc LIKE '%$prodSearch%'";
$result = mysql_query($sql) or die (mysql_error());
while ($row = mysql_fetch_row($result)){
echo $row[0]. ' ' . $row[1] . '<br/>';
}
mysql_free_result($result);
?>
</body>
</html>
This works great for one submission...then of course the next time the page is submitted the value of $prodSearch is the last entered value.
What I would like is a method of allowing the users to "drill down" into the recordset/s.
Sample Table Data
Code:
rsv_desc cost inv
Canon EOS 5 100.00 10
Pentax X 200.00 5
Canon EOS 10 500.00 1
Canon IXUS 49.00 20
In my ideal world...the use would be able to type in "Canon" submit, then type in EOS and the recordset would limit down to only the two CANON EOS Products in the example.
So...my SQL would look something like the following.
Code:
$sql = "select * from d3_import WHERE rsv_desc LIKE '%$prodSearch%' AND LIKE '%$othervariable%'";
My question is how can I go about storing the other variable/s and tacking it on to the end of my select...session variables? Hidden fields? Javascript?
As you may tell, I am new to PHP/MYSQL and I would appreciate any ideas on this.
Thanks in advance.
Peter.
Remember- It's nice to be important,
but it's important to be nice