Echoing MYSQL Search Results On A Seperate Page

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
alex.saidani
Forum Newbie
Posts: 7
Joined: Mon Jan 25, 2010 2:15 pm

Echoing MYSQL Search Results On A Seperate Page

Post 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 :)
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: Echoing MYSQL Search Results On A Seperate Page

Post 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.
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Post Reply