hi,
i have made a search system ,...its like that
i have one table name 'student'
-ID
-Name
-Class
i have textarea where user can search for multiple ids now the problem is how am i going to create a search page..
how to construct the select query....so that it returens results from all the record inserted int the textare.
like this site
http://track.tcs.com.pk/
thanks in advance....!
Having Problem Creating SQL From Textarea
Moderator: General Moderators
-
silenceechoes
- Forum Newbie
- Posts: 1
- Joined: Thu Jul 08, 2004 2:14 am
-
kettle_drum
- DevNet Resident
- Posts: 1150
- Joined: Sun Jul 20, 2003 9:25 pm
- Location: West Yorkshire, England
Split the data in the textarea, by white-spaces or new lines maybe. Then search the database for them:
Code: Select all
$data = explode("<br>", nl2br($_POST['data']));
$sql = "SELECT blah FROM blah WHERE something = 'this'";
foreach($data as $q){
$sql .= " AND name = '$q'";
}
mysql_query($sql);