Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
need paging help for my gallery script
Old 08-13-2005, 07:22 PM need paging help for my gallery script
Junior Talker

Posts: 4
Trades: 0
Aloha,
I've been working on a photo gallery which is slowly, painfully coming together, but I seem to have run into a snag.

I'm getting the thumbnails to come up just fine with paginated results.
I also have it designed so that when you click on a thumbnail a pop up page appears with the full sized picture and it is here on the pop up page where I'm at a loss. I'm grabbing the pictures for the pop up with a query which asks for the picture's ID (pid) and the fighter's ID (fid) just like the one at Sherdog.com. I get the picture in the pop up from the thumbnails page no problemo, but I also want the ability to page through the full sized pop up window of pictures according to that particular fighter's ID (fid) using last, next, previous & first getting the picture's ID (pid). Now all would be great with the script I've got so far, BUT (isn't there always a BUT?) the series of pictures aren't always in order one after the other ie: pic1, pic2, pic6, etc. so I get pages with nothing on them but the navigation where the series has a gap.
I'm looking for a way to have my query and subquery in the //GAPS section of my script
loop until it finds the previous or next picture in the series which matches both in PID and FID.

Here's what's taken me what seems like an eternity so far to come up with.
I'm new to this so if the script looks ugly, bare with me...
PHP Code:
<?
# include connect-file
require_once('includes/connect.inc.php');
# include functions-file
require_once('includes/functions.inc.php');
//GET THE NUM PICS
if(isset($_GET['id']))
{
   
$id $_GET['id'];

if(isset(
$_GET['pid']))
{
   
$pid $_GET['pid'];

// GRABBING TOTAL ROWS (SEEMS REDUNDANT THOUGH)
$getnumrows "SELECT COUNT(pid) as 'norows' from pics WHERE pics.fid = '".$_GET['id']."'";
$therows mysql_query($getnumrows);
$rows     mysql_fetch_array($therowsMYSQL_ASSOC);
$ttlrows $rows['norows'];
// GETTING BEGINNING ROW & PICTURE
$query "SELECT pid as 'pid' from pics WHERE pics.fid = '".$_GET['id']."'";
$result  mysql_query($query);
$row     mysql_fetch_array($resultMYSQL_ASSOC);
$numrows $row['pid'];
// GETTING LAST ROW & PICTURE
$get_max_pid "SELECT MAX(pid) as 'maxpid' FROM pics WHERE pics.fid = '".$_GET['id']."'";
$max_pid =  mysql_query($get_max_pid);
$prow mysql_fetch_array($max_pidMYSQL_ASSOC);
$mpid $prow['maxpid'];

// GAP JUMPING - NOT WORKING 
$gapsql "SELECT pid AS pid, fid AS fid FROM pics WHERE fid = '".$_GET['id']."' AND  pid = ";
// PREVIOUS
$sub_query .=  $_GET['pid'] - 1

$pregap $gapsql $sub_query;
$gap1  mysql_query($pregap);
$prerow mysql_fetch_array($gap1MYSQL_ASSOC);
$previous $prerow['pid'];

// NEXT
$sub_query2 .= $_GET['pid'] + 1

$nextgap $gapsql $sub_query2;
$gap2  mysql_query($nextgap);
$nextrow mysql_fetch_array($gap2MYSQL_ASSOC);
$next $nextrow['pid'];
// END GAP JUMPING -NOT WORKING

// ROOT LINK
$self $_SERVER['PHP_SELF'];

// START LINKS
if ($pid $numrows)
{
//   $pid  = ($_GET['pid'] - 1);
$pid $previous;
 
$prev  "<a href=\"$self?id=$id&amp;pid=$pid\"> &lt; </a>";
 
$first "<a href=\"$self?id=$id&amp;pid=$numrows\"> FIRST </a>\n";
}
else
{
 
$prev  "&nbsp;"// on first page
 
$first "&nbsp;"// on first page
}

if (
$pid $mpid -1)

//   $pid= ($_GET['pid'] + 1);
$pid $next;
 
$next "<a href=\"$self?id=$id&amp;pid=$pid\"> &gt; </a>\n";
 
$last "<a href=\"$self?id=$id&amp;pid=$mpid\"> LAST </a> \n";

else
{
 
$next "&nbsp;"// on the last page
 
$last "&nbsp;"//last page
}
// nav links
echo $first $prev  $next $last

// SHOW BIG PIC
$query "SELECT pics.pid AS 'pid', pics.fid AS 'fid', pics.url AS 'url', pics.thumb AS 'thumb', concat(stats.fname, ' ', stats.lname) AS 'name', stats.fid AS 'fid' FROM pics, stats WHERE pics.fid=stats.fid and stats.fid = '".$_GET['id']."' AND  pics.pid = '".$_GET['pid']."' LIMIT 0, 1";
$results  mysql_query($query);
$picsurl "images/fighter_pics/";

while (
$row mysql_fetch_array($results))
{
list(
$width$height$type$attr) = getimagesize("$picsurl".$row["url"]."");          
echo 
"<img src=\"$picsurl".$row["url"]."\" height=\"$height\" width=\"$width\" alt=\"".$row["name"]."\" class=\"galpic\" /><br />\n";
}
?>
Any help would be greatly appreciated.
Thanks

Last edited by netwit2u; 08-14-2005 at 05:21 AM..
netwit2u is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-14-2005, 03:06 AM
OmuCuSucu's Avatar
Vi Veri Veniversum Vivus

Posts: 1,168
Name: Dragos-Valentin
Location: Cluj-Napoca, RO
Trades: 0
netwit2u, please edit your post and instead of bold tags use php tags. thank you
__________________
.
» Please remember to add to my Talkupation if you enjoyed my post. Thank you :)
.
OmuCuSucu is offline
Reply With Quote
View Public Profile
 
Old 08-14-2005, 05:23 AM
Junior Talker

Posts: 4
Trades: 0
Sorry...
netwit2u is offline
Reply With Quote
View Public Profile
 
Old 08-14-2005, 02:19 PM
Junior Talker

Posts: 2
Trades: 0
I have really only glanced at your problem, but this might help

problem with no pics,

ORDER BY PropertyWeb LIKE 'http://www.a-place%' DESC, PropertyRecip !='' DESC

use the order by MySQL command.

prob with paging

echo "<a href='{$_SERVER['PHP_SELF']}?op=search&page=1&PropertyType=$PropertyType&Prop ertyArea=$PropertyArea'><< First</a>&nbsp;&nbsp;-&nbsp;"; // First Page Link

use the {$_SERVER['PHP_SELF']} command

hope this saves you some time
colourbleu is offline
Reply With Quote
View Public Profile
 
Old 08-14-2005, 08:06 PM
Junior Talker

Posts: 4
Trades: 0
I'm not having a problem with the actual paging. I even have a much simpler script which just gets all the results and numbers them "1 - whatever" and then I simply link to them passing +1 or -1 to the links variable. But this will not work if I go to the pop-up page from a randomly generated thumbnail page, because number 3 on the random page won't necessarily be number three in the result set of the pop up page. Simply put, I want there to be a way to just call sequentially pictures by fighter ID (fid) AND picture ID (pid) ignoring any other pictures of other fighters in between. (GROUP BY FID). But I constantly run into problems when I try to move sequentially from one picture to the next...
They seem to do it quite easily at Sherdog.com as they are also just passing picture ID and fighter ID in the link vars.
Make sense? I'm really new to this, but I know that there has to be a simple solution to what I'm turning into a complicated process.
I'll keep plugging away. I think I need a lo0p somewhere in here...
netwit2u is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to need paging help for my gallery script
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.67325 seconds with 12 queries