PDA

View Full Version : Get users photos from specific



zerocool786
January 15th, 2011, 19:57
I want users to choose, which album they want view their photos to appear on certain page. Everything works fine with my SQL and coding regarding pulling albums ID, or photos id, using separate SQL.
Below is the SQL I use to get users photos from the latest album.



$query1 = "SELECT pid, link, src, src_big, caption FROM photo WHERE aid IN ( SELECT aid FROM album WHERE owner=".$uid.") ORDER BY created DESC LIMIT 4";

Right after WHERE owner=".$uid." I want to enter "AND aid=???" .how do I go about having certain aid number based on what users chooses.

Note:
aid=album id
pid=photo id

when I manually type album id, the query gives me good result. I want to base it on users choose/input.

thanks

themoose
January 20th, 2011, 16:13
Try this;

$query1 = "
SELECT aid,photo.pid, photo.link, photo.src, photo.src_big, photo.caption
FROM photo,album
WHERE aid=???
AND photo.aid=album.aid
AND album.owner=$uid
ORDER BY photo.created DESC LIMIT 4";


Basically it looks for the album id in the `photo` table as long as it's owner = $uid (in the `album` table).