Page 1 of 1

Having Problem Creating SQL From Textarea

Posted: Thu Jul 08, 2004 2:14 am
by silenceechoes
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....!

Posted: Thu Jul 08, 2004 6:35 am
by kettle_drum
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);