jkkenzie Posted December 23, 2008 Share Posted December 23, 2008 <?php if ((isset($_POST["list"])) && ($_POST["list"] == "form1")) { $textAreaValue=$_POST['IDs']; $numbers = explode("\n",$textAreaValue); foreach($numbers as $number) { mysql_select_db($database_app_conn, $app_conn); $getresults = mysql_query("SELECT DISTINCT `Cell Phone`, Telephone, `First Name`, `Middle Name`, `Last Name` FROM members WHERE `ID Number`='$number'"); while($rows = mysql_fetch_array($getresults)) { ?> <tr height="2px"><td height="2px"><?php echo $rows['Cell Phone']; ?></td><td height="2px"><?php echo $rows['Telephone']?></td><td height="2px"><?php echo $rows['First Name']?></td><td height="2px"><?php echo $rows['Middle Name']?></td><td height="2px"><?php echo $rows['Last Name']?></td></tr> <?php } } } ?>Paste Id Numbers Each on its own ROW without mark separting them.. <form method="post" name="form1" action="numbers.php"> <textarea name="IDs" cols="110" rows="10"></textarea> <input type="hidden" name="list" value="form1"><br /> <input type="submit" value="Show the List"> <a href="./numbers.php">REFRESH</a> </form> </table> the above code gives me one result, while its supposed to echo several results under: <tr height="2px"><td height="2px"><?php echo $rows['Cell Phone']; ?></td><td height="2px"><?php echo $rows['Telephone']?></td><td height="2px"><?php echo $rows['First Name']?></td><td height="2px"><?php echo $rows['Middle Name']?></td><td height="2px"><?php echo $rows['Last Name']?></td></tr> I have tried: <?php if ((isset($_POST["list"])) && ($_POST["list"] == "form1")) { $textAreaValue=$_POST['IDs']; $numbers = explode('\n',$textAreaValue); mysql_select_db($database_app_conn, $app_conn); $count=0; foreach($numbers as $number) { $recs[$count]=$number; echo $recs[$count]; $count++; } $count2=0; while ($count2<$count){ If (!empty($recs[$count2])){ $getresults = mysql_query("SELECT DISTINCT `Cell Phone`, Telephone, `First Name`, `Middle Name`, `Last Name` FROM members WHERE `ID Number`='$recs[$count2]'"); $rows = mysql_fetch_assoc($getresults); echo '<tr height="2px"><td height="2px">'.$rows['Cell Phone'].'</td><td height="2px">'. $rows['Telephone'].'</td><td height="2px">'.$rows['First Name'].'</td><td height="2px">'.$rows['Middle Name'].'</td><td height="2px">'.$rows['Last Name'].'</td></tr>'; $count2++; } } } ?> Help Link to comment https://forums.phpfreaks.com/topic/138122-solved-something-wrong/ Share on other sites More sharing options...
jkkenzie Posted December 23, 2008 Author Share Posted December 23, 2008 Print_r gives: Array ( [0] => 11796939 11797063 11798076 ) when i put in my textarea field as below: 11796939 11797063 11798076 Link to comment https://forums.phpfreaks.com/topic/138122-solved-something-wrong/#findComment-722040 Share on other sites More sharing options...
jkkenzie Posted December 23, 2008 Author Share Posted December 23, 2008 when is use "\n" in explode: print_r gives: Array ( [0] => 11798076 [1] => 1179824 [2] => 1181958 ) thanks Link to comment https://forums.phpfreaks.com/topic/138122-solved-something-wrong/#findComment-722042 Share on other sites More sharing options...
jkkenzie Posted December 23, 2008 Author Share Posted December 23, 2008 I have solved the problem: I had not trim() my variable: $val=trim($number); thanks. Link to comment https://forums.phpfreaks.com/topic/138122-solved-something-wrong/#findComment-722044 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.