Jump to content

[SOLVED] Format mysql_fetch_array results


giraffemedia

Recommended Posts

Hi

i've got a mysql_fetch_array query that is returning results fine but i'd like to format the results a bit.

 

At the moment i'm getting rows containing 62, 68, 67, 63, 66, 65 and 64 looking like 62686763666564.

 

How can I turn them into 62, 68, 67, 63, 66, 65, 64

 

I've tried implode but it's not working properly. At the moment i'm getting the results in a while loop as there are many rows that need to be found for the query.

 

Any ideas?

 

Regards

 

James

Link to comment
https://forums.phpfreaks.com/topic/119850-solved-format-mysql_fetch_array-results/
Share on other sites

That might help he he!

 

$issues_query = "SELECT * FROM issues_booked WHERE ib_booking_form_number = $bf_id";

$issues_result = mysql_query ($issues_query);

while ($issues_row = mysql_fetch_array ($issues_result, MYSQL_ASSOC)) {

$rows = $issues_row['ib_issue_number'];

echo $rows . ' ';

}

OK, Heres your code

 

$issues_query = "SELECT * FROM issues_booked WHERE ib_booking_form_number = $bf_id";	
$issues_result = mysql_query ($issues_query);

$data = array();
while ($issues_row = mysql_fetch_array ($issues_result, MYSQL_ASSOC)) {	
$data[] = $issues_row['ib_issue_number'];
}
print implode(", ", $data);

Works a treat Neil thanks.

 

All you're doing there is defining the $data variable as an array? Why is that necessary Neil?

 

I tried using

$data[] = $issues_row['ib_issue_number'];

initially but because I didn't define the array first it didn't work.

 

Do I have to do that every time I want to make a query an array?

 

Regards

 

James

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.