Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.