Solved

Copy SQL record to array.

Posted on 2011-02-22
2
261 Views
Last Modified: 2012-05-11
Hi,

I'm looking for a way to copy all fields within a 'mysql_fetch_assoc' into an array including the key names. I can do this, but can't copy the key names... Could anybody lend a bit of a hand?

Thank you,
Uni
0
Comment
Question by:Unimatrix_001
2 Comments
 
LVL 27

Accepted Solution

by:
Lukasz Chmielewski earned 500 total points
ID: 34949404
Maybe like this:

$q = "select * from table";
$r = mysql_query($q);
while($w = mysql_fetch_assoc($r))
{
    $array[] = $w;
}

print_r($array);

Open in new window

0
 
LVL 3

Author Comment

by:Unimatrix_001
ID: 34949418
Oh... That's a little simpler than what I had... :S
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question