Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

searching a list of values

Status
Not open for further replies.

3inen

Technical User
May 26, 2005
51
US
Hi! i have a search form where the user can copy and paste a list of values (one per line) and i would want to search each of those against the mysql database and return the result.

using the below code, i am able to read through each line of the input but i am getting the result for only the last line of input.

any help would be appreciated.

thanks

$pieces=$_POST["search"];

$array = explode("\n", $pieces);

$today = date('l jS F Y');


foreach($array as $arrayid){

$result = mysql_query("SELECT array.array_id, num, 1week, 6week, 10week FROM array LEFT JOIN array2 USING (array_id) WHERE array.array_id LIKE '%$arrayid%'");

$r=mysql_fetch_array($result);
$id=$r["array_id"];
$num=$r["num"];
$ten=$r["10week"];
$one=$r["1week"];
$six=$r["6week"];

//display the row

echo "Array ID: $id <br>num: $num <br> 10Week: $ten <br> 1Week: $one <br> 6Week: $six <br> ";
echo "<br>---------------------------------------------<br>";
}

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top