Hi guys,
I have a simple search function in php which gets info from my database which works fine. This is a simple search which gets all data on specific products. I would then like to do an advanced search on the results from the first search. I was thinking of passing the first set of results as a session variable to another page and do more search from there. I have used the same method of passing variables which have worked before but it wont work for my search results.
Below is the code i have used to try and display my search results on a new page.
ps i have used the session_start on required pages. Also i dont think when echoing out into the table i have done it right either with the session variables.
Here is the code for the first search i have done.
Can anyone help me with this please.
Thanks
I have a simple search function in php which gets info from my database which works fine. This is a simple search which gets all data on specific products. I would then like to do an advanced search on the results from the first search. I was thinking of passing the first set of results as a session variable to another page and do more search from there. I have used the same method of passing variables which have worked before but it wont work for my search results.
Below is the code i have used to try and display my search results on a new page.
Code:
<?php
$_SESSION['result'];
echo "<table class='searchTable' border='1'; <tr>";
for($i = 0; $i < mysql_num_fields.$_SESSION['result']; $i++) {
$field_info = mysql_fetch_field($_SESSION['result'], $i);
echo "<th>{$field_info->name}</th>"; }
// Print the data
while($row = mysql_fetch_row($result)) {
echo "<tr>";
foreach($row as $_column) {
echo "<td>{$_column}</td>"; }
echo "</tr>";
}
echo "</table>";
?>
ps i have used the session_start on required pages. Also i dont think when echoing out into the table i have done it right either with the session variables.
Here is the code for the first search i have done.
Code:
$query = ("SELECT * FROM ($table) WHERE upper($field) LIKE '%" . $find . "%'");
$result = mysql_query($query);
echo "<table class='searchTable' border='1'; <tr>";
for($i = 0; $i < mysql_num_fields($result); $i++) {
$field_info = mysql_fetch_field($result, $i);
echo "<th>{$field_info->name}</th>"; }
// Print the data
while($row = mysql_fetch_row($result)) {
echo "<tr>";
foreach($row as $_column) {
echo "<td>{$_column}</td>"; }
echo "</tr>";
}
echo "</table>";
Can anyone help me with this please.
Thanks