PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
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.
$db =& JFactory::getDBO();
/**
* Cast album ID to int to prevent possible SQL injection even though data looks relatively safe. You
* could also use mysql_real_escape_string but casting to an int seems simpiler and essentially provides
* the same result in regards to avoiding SQL injection.
*/
$query = "SELECT * FROM jos_photos where albumid = ".$album->id." ORDER BY id ASC";
/**
* The return value of mysql_query when selecting data is either false (failed query) or result resource (success)
*/
//echo $query;
//$result = mysql_query($query);
$db->setQuery($query);
$results = $db->loadObjectList();
//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(count($results)) {
foreach($results as $row) {
//echo $row->id;
//echo $row->thumbnail;