Page 1 of 1

data put in a array

Posted: Sat Nov 08, 2008 3:01 am
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

Re: data put in a array

Posted: Sat Nov 08, 2008 3:22 pm
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().