Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Dec 2004
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation 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>

  • #2
    New Coder
    Join Date
    Dec 2004
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation Got the query to run correct, but still not retunign the rows of photos

    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..

    Code:
    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\wamp\www\xxx\photos.album.php on line 126

  • #3
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    Kill your query off to see if it's just bad SQL: $photos = mysql_query($query) or die(mysql_error());
    The fetch is definitely required. $photos would just be a resultset resource, so you need to pull the data off in a while loop. The error on your fetch_array is typically associated with providing it false, which is the result of a failed query.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •