I need some solution to select photos which are marked as “public” or marked “for friends”. I don’t have an idea how is it possible.
Is it easy to select public photos:
$result = mysql_query("SELECT filename, ownerid, etc... FROM photos
WHERE public='1' order by id DESC limit $start, $step") or die('Error');
or even photos marked “for friends”
$result = mysql_query("SELECT filename, ownerid, etc... FROM photos
WHERE public='1' or for_friends='1' order by id DESC limit $start, $step") or die('Error');
But… each photo belongs to a different owner and before selecting them the query must know if I am a friend of the owner of this photo.
Assuming you have a
friendstable which maps users with their friends, having columnsuser_idandfriend_user_id, then your query should be something like this :