I have an issue where i have a textarea in a form where users can enter names on seperate lines. On submit I explode the " ".
I then want to pass the values from the array into an Select statement, but when i run the script it only returns one result (the last one) from the array..
here is the code below.
echo "<h1> You searched for the following names </h1>";
include 'conn.php';
mysql_select_db("email_finder", $con);
$Email = $_POST['EmailBox'];
$str = $Email;
$lines = explode("
", $str);
//$in = implode(',', $lines);
//$userStr = implode(',', $lines);
echo "<table border='0'>
<tr>
<th style='color:White' width='180px'; bgcolor=#999999>Name</th>
<th style='color:White' width='250px'; bgcolor=#999999>Email</th>
</tr>";
echo "<pre>";
print_r($lines);
echo "</pre>";
foreach($lines as $array_element) {
$result = mysql_query("SELECT * FROM `emails` WHERE `Name` IN('$array_element') ORDER BY `LastName`");
echo "<pre>";
print_r($array_element);
echo "</pre>";
while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) {
echo "<tr>";
echo "<td style='padding-left:5px'><b> ".$row['Name']."</b> : </td>";
printf("<td style='padding-left:5px'><a href=mailto:" .$row['Email']. ">" .$row['Email']. "</a></td>");
echo "</tr>";
echo "<pre>";
print_r($row);
echo "</pre>";
}
}
echo "</table><br />";
echo "Email <b>ALL</b> these Students: <a href=mailto:".$row['Email']." >Click Here</a> <br />";
mysql_close($con);
echo '<br />';
If you can help i would be greatful
Thanks