lalnfl Posted April 24, 2011 Share Posted April 24, 2011 $array = array("1","2","3"); foreach ($array as $value){ echo $value; } Put its only echoing out 3, not the whole array. Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted April 24, 2011 Share Posted April 24, 2011 It should echo "123" Try <?php $array = array("1","2","3"); foreach ($array as $value){ echo $value . '<br>'; } ?> Another way to do this is <?php $array = array("1","2","3"); echo implode('<br>',$array); ?> Ken Quote Link to comment Share on other sites More sharing options...
fugix Posted April 24, 2011 Share Posted April 24, 2011 Try printr($array) to see what displays Quote Link to comment Share on other sites More sharing options...
lalnfl Posted April 24, 2011 Author Share Posted April 24, 2011 $sql_get_worker = mysql_query("SELECT id FROM Worker WHERE mem_id='$id' AND retired='n'"); $get_worker = mysql_fetch_assoc($sql_get_worker); foreach ($get_worker as $value){ $sql_get_worker = mysql_query("SELECT * FROM Worker WHERE id='$value'"); $get_worker = mysql_fetch_array($sql_get_worker); $worker_firstname = $get_worker['firstname']; $worker_lastname = $get_worker['lastname']; $worker_options .= "<option value='$value'>$worker_firstname $worker_lastname</option>"; } How about this then? There are two rows that return with this id, but yet only one is returning. Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted April 24, 2011 Share Posted April 24, 2011 Each iteration of mysql_fetch_assoc() only retrieves one record. You need a while() loop if you're expecting the result set to be more than one record. Quote Link to comment Share on other sites More sharing options...
lalnfl Posted April 24, 2011 Author Share Posted April 24, 2011 Now I see it. Thanks! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.