Page 1 of 1
Search Item
Posted: Tue Aug 03, 2004 8:34 pm
by S_henry
In my system, I have 1 search function to search student record. To search the student record, I just have to enter the student ID and then click the search button. Then the result will be displayed in 1 list. When I want to search for the second time, I want to display the result without remove the first result in that list. That's mean The result for the second search will be displayed with the result of the first one and so on. I think 1 of the solution is by using cookie. Can anybody explain how to do that pls? Thanx..
Posted: Tue Aug 03, 2004 11:36 pm
by kettle_drum
Or just keep passing the previous search to the next page and then do a:
Code: Select all
SELECT * FROM students WHERE id = '$_POSTїsearch]' OR id = '$_POSTїsearch2]' OR id = '$_POSTїsearch3]';
Posted: Wed Aug 04, 2004 1:14 am
by S_henry
In that SELECT statement, actually 'search' (from $_POST[search]) is variable name that we pass to search the item is it? In that statement also, just got 'search'...'search3' only. How about if we want to search the item until 10 times or more? Sorry if I misunderstood. Can anybody explain it pls? Thanx..
Posted: Wed Aug 04, 2004 1:25 am
by kettle_drum
Well that was just an example. In pratice you will have to produce a loop that will continue to add the search terms to the query. Might make it easier if you pass the number of search terms in the form as well, then you can just do:
Code: Select all
$sql = "SELECT * FROM students WHERE id = '$_POST[search]'";
for($x=1;$x<$_POST['number'];$x++){
$sql .= " OR id = '$_POST[search-".$x."]'";
}
Posted: Wed Aug 04, 2004 1:43 am
by S_henry
I see. Now I understand. Thanx kettle_drum.
