Jump to content

Getting info from database


php_beginner_83

Recommended Posts

Hi All

 

I'm not sure if this is a php problem or mysql but I'm having a problem trying to get info from my database. 

 

Currently, this is my code to get all the info I need..

 

$result = mysql_query("SELECT * FROM pictures 
INNER JOIN pics_in_albums 
ON pictures.ID = pics_in_albums.PicID 
INNER JOIN albums 
ON pics_in_albums.AlbumID = albums.ID 
WHERE albums.ID = \"$albumID\"") or die(mysql_error());

 

What I'm trying to do is display a picture then underneath have a description displayed.  Both the image path and description of the photo are stored in the database.  In my 'pictures' table, I have the fields 'ID', 'Description', 'Path'.  In my 'albums' table i have, 'ID', 'Title', 'Description', 'Place'. 

 

However, when I use the following code, the 'Description' from the 'albums' table is displayed and not the one from 'pictures' table. 

 

while ($row = mysql_fetch_array($result)) 
{
$descriptions[$counter] = $row['Description'];
$paths[$counter] = substr(strrchr($row['Path'],92),1);

        $counter++;
   
}

 

I've been trying to fix it but not having any success, does anyone have any ideas??

 

Thank you.

Link to comment
https://forums.phpfreaks.com/topic/174917-getting-info-from-database/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.