bigdspbandj Posted November 24, 2007 Share Posted November 24, 2007 I am trying to add the results of a query (specifically a particular field's value) to a new array. The result is either an empty array or the last row in the query result instead of all the rows. Here is my code: // query job_status table for current job_id $status_sql = "SELECT * FROM ct_job_status WHERE job_id = $job_id"; $status_result = mysql_query($status_sql); $status_count = mysql_num_rows($status_result); // loop results to build a $completed_status array $completed = array(); while ($status_rows = mysql_fetch_assoc($status_result)) { $completed[] = $status_rows['status_label']; } echo '<pre>'; print $completed; echo '</pre>'; Any help would be greatly appreciated. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/78690-solved-add-sql-result-to-an-array/ Share on other sites More sharing options...
Psycho Posted November 24, 2007 Share Posted November 24, 2007 Well you can't use print on an array. Try print_r() instead. Quote Link to comment https://forums.phpfreaks.com/topic/78690-solved-add-sql-result-to-an-array/#findComment-398259 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.