Jump to content

[SOLVED] Add sql result to an array


bigdspbandj

Recommended Posts

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!

Link to comment
https://forums.phpfreaks.com/topic/78690-solved-add-sql-result-to-an-array/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.