Solved

Copy SQL record to array.

Posted on 2011-02-22
2
259 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

757 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now