Solved

Copy SQL record to array.

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

912 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

15 Experts available now in Live!

Get 1:1 Help Now