Catweasel
Catweasel

Reputation: 1

PHP Display a search result from MySQL Search

I have three php pages:

  1. search.php which sets out a form with fields which are used to query a MYSQL database
  2. query.php which queries the database with variables set in search.php, and return a result array (which can be a large array), then redirect to result.php
  3. result.php , display the results in a table form. This page is not connected to the database, and this page is also bookmarkable, ie if someone bookmarks that page, it will display the result again without quering the database.

My problem is that I don't know how to make the result page bookmarkable.. I used session to carry the variable from query.php to result.php but once the browser is closed, the result page will display nothing.

If someone can help, it will be highly appreciated.

Upvotes: 0

Views: 736

Answers (1)

David Yue
David Yue

Reputation: 725

1. Bookmarks:
From what I know, browser bookmarks save the link to a page, so it would be wise to use $_GET[] variables with all the fields in the form so that every time some one visits the page, the server will know the search parameters automatically from the URL
Eg.

$search = $_GET["s"]
//Query database for parameter $search 

They would bookmark a link like this:
www.example.com/result.php?s=snoopy
Now the server would know "snoopy" is the search term.

2. Saving Data

"if someone bookmarks that page, it will display the result again without quering the database."

Unless you are planning to download the information, I don't think there is a way to load the data without querying the database again. But I bet there's some convoluted way to do it hidden somewhere in Browser Cookies or something like that... I don't think it's worth going that far though.

Upvotes: 1

Related Questions