/    Sign up×
Community /Pin to ProfileBookmark

Need help getting photos in array and display in loop, returning none now

I am trying to return all the photos in the database that has the albumid associated with that table info. I can echo the $album->id (albumid) no problem, but my query it think is somewhat off. Please anyone.

[code]
<div id=”photo-items” class=”photo-list-item”>
<?php
echo $album->id.'<br>’;

// fetch album photos and ids
$database =& JFactory::getDBO();
$query = “SELECT * FROM jos_photos where albumid = “.$album->id.” ORDER BY ASC”;
$photos = mysql_query($query); //This returns and array of photos, but then needs to display all the photos in loop below, but it not retuning none, even if there is 100 photos in table and in the folder directory

if($photos)
{
for( $i=0; $i<count($photos); $i++ ){
$row =& $photos[$i];
?>
<div class=”photo-item” id=”photo-<?php echo $i;?>” title=”<?php echo $this->escape($row->caption);?>”>
<a href=”<?php echo $row->link;?>”><img class=”” src=”<?php echo $row->getThumbURI();?>” alt=”<?php echo $this->escape($row->caption);?>” id=”photoid-<?php echo $row->id;?>” /></a>
<?php
if( $isOwner )
{
?>
<div class=”photo-action”>
<a href=”javascript:void(0);(‘<?php echo $row->id;?>’);” class=”remove”><?php echo JText::_(‘CC REMOVE’);?></a>
</div>
<?php
}
?>
</div>
<?php
}
}
else
{
?>
<div class=”empty-list”><?php echo JText::_(‘CC NO PHOTOS UPLOADED YET’);?> <button class=”button button-upload” href=”javascript: void(0);&amp;userid=88″ id=”upload-photos-button”>Start Uploading</button></div>
<?php
}
?>
</div>

[/code]

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@danjaproauthorApr 16.2012 — I fixed the $query to return the correct row when I run it in MySQL directly in the database but on php code , here is the error I am getting now..

<i>
</i>Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:wampwwwxxxphotos.album.php on line 126

×

Success!

Help @danjapro spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...