Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-10-2010, 12:57 PM   PM User | #1
a_80
New to the CF scene

 
Join Date: Jan 2010
Location: Uppsala, Sweden
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
a_80 is an unknown quantity at this point
Variable array with data from MySQL

Hi!

I'm an hobby-programmer in PHP and MySQL that has run into a problem.
I've been reading about variable variables in PHP, but can't get it to work for the specific case I need it to. Here's the set-up:

I have a table named participants. The participants have one line each, but are mostly paired up in couples. This is done by a column named id - so two lines have the same value (1, 2, 3...) in the id-column.
I then query the database (aocuserlogin is a cookie set by a simple loginscript)
$qloadarray = mysql_query("SELECT * FROM participants WHERE (id='$aocuserlogin')");
while ($rloadarray = mysql_fetch_array($qloadarray, MYSQL_ASSOC)) {
$loadedarray = array($rloadarray[firstcolumn],$rloadarray[secondcolumn],$rloadarray[thirdcolumn]);
}

Since the while-loop is going to run twice I want to set the variable for the array to a name from the specific row that is running.
I mean I want the variable to be named as the value in the fourth column of the active row - does that make sense?

I have been trying something like
$$rloadarray[fourthcolumn] = array(...
but this doesn't work.
I've also tried
${$rloadarray[fourthcolumn]} = array(...
Which doesn't work either...

Does someone have an idea?

Please ask if you need additional information - it's hard to explain...

Thanks a million!!!
a_80 is offline   Reply With Quote
Old 01-10-2010, 07:54 PM   PM User | #2
Rebbu
Regular Coder

 
Join Date: Nov 2009
Location: Hamilton, New Zealand
Posts: 126
Thanks: 0
Thanked 17 Times in 17 Posts
Rebbu is on a distinguished road
PHP Code:
<?php
$a
[$rloadarray[fourthcolumn]] = array($rloadarray[firstcolumn],$rloadarray[secondcolumn],$rloadarray[thirdcolumn]);

?>
Not exactly what you wanted, but easier to keep track of in my opinion.
__________________
Affordable Web Design (New Zealand Based)
Internet Marketing Guru
PHP/mySQL Expert
-------------------------------------------
Rebbu is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:21 AM.


Advertisement
Log in to turn off these ads.