Page 1 of 1

Echoing MYSQL Search Results On A Seperate Page

Posted: Sun Feb 07, 2010 7:05 am
by alex.saidani
I have written a php search engine script that echos the results rather than sending it to a different page and echoing them there, i have managed to get the script to send it to a different page but i don't know how to echo the results on that page, this is the code im using to send it to a different page:

Code: Select all

 
    $numrows = mysql_num_rows($result);
    $numrows2 = mysql_num_rows($result);
    if ($numrows == 0) {
    $send1 = "/results/noresults.php";
    header("location:$send1");
     }
    
    if ($numrows2 == 1) {
    $send2 = "/results/result.php";
    header("location:$send2");
  }
   
    else{
    $send3 = "/results/results.php";
    header("location:$send3");
}
 
If anyone could help me on echoing the results on a different page that would be great.
Thanks in advance :)

Re: Echoing MYSQL Search Results On A Seperate Page

Posted: Sun Feb 07, 2010 9:38 am
by social_experiment
What if you redirected the page with something like :

Code: Select all

<?php header('location: pageToGoTo.php?id=$valueFromDb'); ?>
The id could be something that you pulled from the database that is specific (unique) to each record and on the pageToGoTo.php, you have a query that uses that id in a manner similar to this :

Code: Select all

<?php $query = mysql_query("SELECT * FROM table WHERE id = '".addslashes($_GET['id'])."' LIMIT 1 ");?>
You would have to do certain checks on the value you receive from your query string to makes sure it is in the valid format you wish to use.