data put in a array

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
cade
Forum Commoner
Posts: 55
Joined: Tue Jul 03, 2007 8:18 pm

data put in a array

Post by cade »

Code: Select all

$gtInfo = "select * from donator where 1 order by date_posted desc";
$exInfo = mysql_query($gtInfo) or die(mysql_error);
$item = array();
while ($rw = mysql_fetch_array($exInfo))
{
    $item[] = array('id' => $rw['id'],
                  'item_title' => $rw['item_title'],
                  'email' => $rw['email'],
                  'donator_name' => $rw['donator_name'],
                  'notes' => $rw['notes'],
                  'country' => $rw['country'],
                  'date_posted' => $rw['date_posted'],
                  'date_expired' => $rw['date_expired'],
                  'viewed' => $rw['viewed'],
                  'place' => $rw['place']);
}
I've trying this for few hours to display the data. How to display the item_title
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: data put in a array

Post by califdon »

cade wrote:I've trying this for few hours to display the data. How to display the item_title
I'm assuming you have some need to store the results in an array? In general, you don't need to do that, but you may have some reason to do so. So, to print out the item_title for, say, the third row, you would need to do something like:

Code: Select all

echo $item[2]['title'];
You could also print out the complete array using the PHP function print_r().
Post Reply