Welcome to Dream.In.Code
Getting PHP Help is Easy!

Join 132,672 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,165 people online right now. Registration is fast and FREE... Join Now!




PHP Gallery (previous and next photo) how to do it?

 
Reply to this topicStart new topic

PHP Gallery (previous and next photo) how to do it?

Xmod
post 7 Aug, 2007 - 08:06 AM
Post #1


New D.I.C Head

*
Joined: 19 Jan, 2007
Posts: 35


My Contributions


Hey guys! Im doing a gallery where users can post photos and display them on the web my problem is I dont know how to pick the next photo from the database from a certain user...here is my table structure: (is in the 1.gif Attached)... Lets say im in the first photo how would I be able to get the info for the next photo? I though it was easy but because the script is gonna have different users I can't just add 1 to the post_id. Is there anyway of selecting the current one and going down or up? I came up with this code

CODE

$q3 = "SELECT * FROM flogPost WHERE post_userid = '$userId' ORDER BY post_id DESC limit 0,1";
$r3 = mysql_query($q3) or die(mysql_error());
$nextFoto = mysql_fetch_array($r3);
//sacando la foto previa?
$q4 = "SELECT * FROM flogPost WHERE post_userid = '$userId' ORDER BY post_id ASC limit 0,1";
$r4 = mysql_query($q4) or die(mysql_error());
$prevFoto = mysql_fetch_array($r4);


The code doesnt work because the only thing I'm doing is selecting the very first picture of the user and the very last one... Please help me a bit thanks.

This post has been edited by Xmod: 7 Aug, 2007 - 08:07 AM


Attached thumbnail(s)
Attached Image
User is offlineProfile CardPM

Go to the top of the page

snoj
post 7 Aug, 2007 - 08:12 AM
Post #2


$Null

Group Icon
Joined: 31 Mar, 2003
Posts: 3,304



Thanked 5 times

Dream Kudos: 700
My Contributions


Why doesn't it work? You never say.
User is offlineProfile CardPM

Go to the top of the page

Xmod
post 7 Aug, 2007 - 08:46 AM
Post #3


New D.I.C Head

*
Joined: 19 Jan, 2007
Posts: 35


My Contributions


QUOTE(hotsnoj @ 7 Aug, 2007 - 09:12 AM) *

Why doesn't it work? You never say.

It doesnt work because its selecting the last and the first picture from the database what im trying to do is if Im in the first picture display a link to the next one and so on... you understand now?
User is offlineProfile CardPM

Go to the top of the page

Xmod
post 7 Aug, 2007 - 10:01 AM
Post #4


New D.I.C Head

*
Joined: 19 Jan, 2007
Posts: 35


My Contributions


Ok I found the solution tongue.gif

CODE

$q3 = "SELECT * FROM flogPost WHERE post_id > '$rowPost[post_id]' and post_userid = '$userId'  ORDER BY post_id  ASC limit 0,1";
$r3 = mysql_query($q3) or die(mysql_error());
$nextFoto = mysql_fetch_array($r3);
//sacando la foto previa?
$q4 = "SELECT * FROM flogPost WHERE post_id < '$rowPost[post_id]' and post_userid = '$userId'  ORDER BY post_id  DESC limit 0,1";
$r4 = mysql_query($q4) or die(mysql_error());
$prevFoto = mysql_fetch_array($r4);
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/23/08 06:08AM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month