Hi,
This is probably really easy, but my PHP skills arent very good so any assistance would be most welcome.
I have a db query like this.
$query = "SELECT imagesrc FROM #__adverts_images WHERE advertid = ".(int) $row->id;
$db->setQuery($query);
$imagerows = $db->loadObjectList();
i am then placing the $imagerows into a session variable like this;
$_SESSION['images'] = $imagerows;
then I want to add a new record into the object list like this;
$_SESSION['images'][count($_SESSION['images'])] = array("imagesrc"=>'image.jpg');
then im passing this array to a function that outputs the list of images like this;
function showImages($images) {
foreach($images as $image)
{
?>
}
}
The images loaded directly from the database show fine. But I cant get the dynamically added image to show.
I belive it is because I have formated the object wrongly, but I dont know how to fix.
Thanks
Richard
Adding object into object list
Moderators: tjay, seadap, Rogue4ngel, matthewhayashida
Forum rules
-
- Joomla! Fledgling
- Posts: 3
- Joined: Fri Jan 18, 2008 2:32 am
-
- Joomla! Fledgling
- Posts: 3
- Joined: Fri Jan 18, 2008 2:32 am
Re: Adding object into object list
OK, after a few more hours I found i could do it like this.
$newimage = new stdClass;
$newimage->imagesrc = 'image.jpg';
$_SESSION['images'][count($_SESSION['images'])] = $newimage;
So it was the format.
$newimage = new stdClass;
$newimage->imagesrc = 'image.jpg';
$_SESSION['images'][count($_SESSION['images'])] = $newimage;
So it was the format.