Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > MySQL
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
MySQL General discussion about the MySQL database.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the MySQL section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 13th, 2006, 09:47 AM
Registered User
Join Date: Feb 2006
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Mysql,PHP and arrays

I'm trying to retrieve data from a mysql table using a select statement and store the data in an array. I then want to go through the array and assign certain elements of the array to variables. To try and do this, I used the following code

$get_table = mysql_query("SELECT * from $table
            where USER_ID = '5'");

$row_50 = array();
while ($row_50 = mysql_fetch_row( $get_table) )

I assumed that the while statement used with the array push command would push each row returned into the $ret50 array.

However, when I use the following to retrieve the first eight elements of the array and display the contents of the $_SESSION variables, they print the word Array to the browser.

$_SESSION['1TG1'] = $ret50[0];
$_SESSION['1WG1'] = $ret50[1];
$_SESSION['1DG1'] = $ret50[2];
$_SESSION['1LG1'] = $ret50[3];
$_SESSION['1SG1'] = $ret50[4];
$_SESSION['1AG1'] = $ret50[5];
$_SESSION['1GD1'] = $ret50[6];
$_SESSION['1PG1'] = $ret50[7];

Any idea's of what I'm doing wrong..?

Reply With Quote
  #2 (permalink)  
Old February 15th, 2006, 07:55 AM
Friend of Wrox
Join Date: Mar 2004
Location: Bhopal, MP, India.
Posts: 357
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to anshul

You're doing too much wrong ..:D:D
$rs_id = array();
$query = MySQL SELECT * query;
$result = mysql_query($query);
while( $row = mysql_fetch_array($result) ) {
    $rs_id[] = $row['id'];
    $rs_name[] = $row['id'];
    $rs_email[] = $row['id'];
Now use the arrays as you like:

mediasworks.com project
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP array_push() for associative arrays mcmahonc Beginning PHP 1 January 9th, 2010 01:13 PM
HOW TO USE STRINGS,ARRAYS AND VARIABLES IN PHP jhan316 Beginning PHP 1 July 25th, 2006 07:17 PM
sendAndLoad Arrays to MySQL harpua Flash (all versions) 1 May 11th, 2006 07:40 PM
php compare 2 arrays lucian PHP How-To 0 February 23rd, 2006 12:53 PM
Converting mysql arrays to strings robertjshillito Beginning PHP 3 February 25th, 2005 04:11 PM

All times are GMT -4. The time now is 01:44 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.