Jump to content

DW Photo Gallery


Recommended Posts

I've put together a very simple photo gallery. You can view a list of thumbnails, which when clicked will (duh) show you the larger picture, or you can select a gallery from a pulldown, which will then show you the first large picture in that category, complete with nex/prev pagination.

 

So photo category '1' has 3 images in it, each with their own id, which makes a total of 3 records in the table.

 

Okay, so when a user clicks on image 1 thumb, the large pic is displayed. When clicking on the next button, it should move to image 2, but it doesn't. It just refreshes image 1. This happens with any thumb that's clicked. If the user clicks on thumb 5, the large image 5 is displayed, but the pagination doesn't work.

 

I can't figure out how to get the page to know what record it's on and go from there!

 

Here's the code for the large pic page, with pagination

[!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--][span style=\"color:#0000BB\"]<?php [/span][span style=\"color:#007700\"]require_once([/span][span style=\"color:#DD0000\"]\'../Connections/cranes.php\'[/span][span style=\"color:#007700\"]); [/span][span style=\"color:#0000BB\"]?>

<?php

$currentPage [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$_SERVER[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\"PHP_SELF\"[/span][span style=\"color:#007700\"]];

 

[/span][span style=\"color:#0000BB\"]$maxRows_rs_photogal_imgs [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]1[/span][span style=\"color:#007700\"];

[/span][span style=\"color:#0000BB\"]$pageNum_rs_photogal_imgs [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]0[/span][span style=\"color:#007700\"];

if (isset([/span][span style=\"color:#0000BB\"]$_GET[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'pageNum_rs_photogal_imgs\'[/span][span style=\"color:#007700\"]])) {

  [/span][span style=\"color:#0000BB\"]$pageNum_rs_photogal_imgs [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$_GET[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'pageNum_rs_photogal_imgs\'[/span][span style=\"color:#007700\"]];

}

[/span][span style=\"color:#0000BB\"]$startRow_rs_photogal_imgs [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$pageNum_rs_photogal_imgs [/span][span style=\"color:#007700\"]* [/span][span style=\"color:#0000BB\"]$maxRows_rs_photogal_imgs[/span][span style=\"color:#007700\"];

 

[/span][span style=\"color:#0000BB\"]mysql_select_db[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$database_cranes[/span][span style=\"color:#007700\"], [/span][span style=\"color:#0000BB\"]$cranes[/span][span style=\"color:#007700\"]);

if (isset([/span][span style=\"color:#0000BB\"]$_GET[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'id\'[/span][span style=\"color:#007700\"]])) {

    [/span][span style=\"color:#0000BB\"]$id [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$_GET[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'id\'[/span][span style=\"color:#007700\"]];

}

[/span][span style=\"color:#0000BB\"]mysql_select_db[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$database_cranes[/span][span style=\"color:#007700\"], [/span][span style=\"color:#0000BB\"]$cranes[/span][span style=\"color:#007700\"]);

if (isset([/span][span style=\"color:#0000BB\"]$_GET[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'cat\'[/span][span style=\"color:#007700\"]])) {

    [/span][span style=\"color:#0000BB\"]$cat [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$_GET[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'cat\'[/span][span style=\"color:#007700\"]];

    [/span][span style=\"color:#0000BB\"]$query_rs_photogal_imgs [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#DD0000\"]\"SELECT * FROM photogal_imgs WHERE category = \'$cat\'\"[/span][span style=\"color:#007700\"];

} else {

    [/span][span style=\"color:#0000BB\"]$query_rs_photogal_imgs [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#DD0000\"]\"SELECT * FROM photogal_imgs WHERE id = \'$id\'\"[/span][span style=\"color:#007700\"];

}

[/span][span style=\"color:#0000BB\"]$query_limit_rs_photogal_imgs [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]sprintf[/span][span style=\"color:#007700\"]([/span][span style=\"color:#DD0000\"]\"%s LIMIT %d, %d\"[/span][span style=\"color:#007700\"], [/span][span style=\"color:#0000BB\"]$query_rs_photogal_imgs[/span][span style=\"color:#007700\"], [/span][span style=\"color:#0000BB\"]$startRow_rs_photogal_imgs[/span][span style=\"color:#007700\"], [/span][span style=\"color:#0000BB\"]$maxRows_rs_photogal_imgs[/span][span style=\"color:#007700\"]);

[/span][span style=\"color:#0000BB\"]$rs_photogal_imgs [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]mysql_query[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$query_limit_rs_photogal_imgs[/span][span style=\"color:#007700\"], [/span][span style=\"color:#0000BB\"]$cranes[/span][span style=\"color:#007700\"]) or die([/span][span style=\"color:#0000BB\"]mysql_error[/span][span style=\"color:#007700\"]());

[/span][span style=\"color:#0000BB\"]$row_rs_photogal_imgs [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]mysql_fetch_assoc[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$rs_photogal_imgs[/span][span style=\"color:#007700\"]);

 

if (isset([/span][span style=\"color:#0000BB\"]$_GET[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'totalRows_rs_photogal_imgs\'[/span][span style=\"color:#007700\"]])) {

  [/span][span style=\"color:#0000BB\"]$totalRows_rs_photogal_imgs [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$_GET[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'totalRows_rs_photogal_imgs\'[/span][span style=\"color:#007700\"]];

} else {

  [/span][span style=\"color:#0000BB\"]$all_rs_photogal_imgs [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]mysql_query[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$query_rs_photogal_imgs[/span][span style=\"color:#007700\"]);

  [/span][span style=\"color:#0000BB\"]$totalRows_rs_photogal_imgs [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]mysql_num_rows[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$all_rs_photogal_imgs[/span][span style=\"color:#007700\"]);

}

[/span][span style=\"color:#0000BB\"]$totalPages_rs_photogal_imgs [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]ceil[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$totalRows_rs_photogal_imgs[/span][span style=\"color:#007700\"]/[/span][span style=\"color:#0000BB\"]$maxRows_rs_photogal_imgs[/span][span style=\"color:#007700\"])-[/span][span style=\"color:#0000BB\"]1[/span][span style=\"color:#007700\"];

 

[/span][span style=\"color:#0000BB\"]$queryString_rs_photogal_imgs [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#DD0000\"]\"\"[/span][span style=\"color:#007700\"];

if (&[/span][span style=\"color:#FF8000\"]#33;empty($_SERVER[\'QUERY_STRING\'])) {

  [/span][span style=\"color:#0000BB\"]$params [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]explode[/span][span style=\"color:#007700\"]([/span][span style=\"color:#DD0000\"]\"&\"[/span][span style=\"color:#007700\"], [/span][span style=\"color:#0000BB\"]$_SERVER[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'QUERY_STRING\'[/span][span style=\"color:#007700\"]]);

  [/span][span style=\"color:#0000BB\"]$newParams [/span][span style=\"color:#007700\"]= array();

  foreach ([/span][span style=\"color:#0000BB\"]$params [/span][span style=\"color:#007700\"]as [/span][span style=\"color:#0000BB\"]$param[/span][span style=\"color:#007700\"]) {

    if ([/span][span style=\"color:#0000BB\"]stristr[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$param[/span][span style=\"color:#007700\"], [/span][span style=\"color:#DD0000\"]\"pageNum_rs_photogal_imgs\"[/span][span style=\"color:#007700\"]) == [/span][span style=\"color:#0000BB\"]false [/span][span style=\"color:#007700\"]&&

        [/span][span style=\"color:#0000BB\"]stristr[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$param[/span][span style=\"color:#007700\"], [/span][span style=\"color:#DD0000\"]\"totalRows_rs_photogal_imgs\"[/span][span style=\"color:#007700\"]) == [/span][span style=\"color:#0000BB\"]false[/span][span style=\"color:#007700\"]) {

      [/span][span style=\"color:#0000BB\"]array_push[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$newParams[/span][span style=\"color:#007700\"], [/span][span style=\"color:#0000BB\"]$param[/span][span style=\"color:#007700\"]);

    }

  }

  if ([/span][span style=\"color:#0000BB\"]count[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$newParams[/span][span style=\"color:#007700\"]) &[/span][span style=\"color:#FF8000\"]#33;= 0) {

    [/span][span style=\"color:#0000BB\"]$queryString_rs_photogal_imgs [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#DD0000\"]\"&\" [/span][span style=\"color:#007700\"]. [/span][span style=\"color:#0000BB\"]htmlentities[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]implode[/span][span style=\"color:#007700\"]([/span][span style=\"color:#DD0000\"]\"&\"[/span][span style=\"color:#007700\"], [/span][span style=\"color:#0000BB\"]$newParams[/span][span style=\"color:#007700\"]));

  }

}

[/span][span style=\"color:#0000BB\"]$queryString_rs_photogal_imgs [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]sprintf[/span][span style=\"color:#007700\"]([/span][span style=\"color:#DD0000\"]\"&totalRows_rs_photogal_imgs=%d%s\"[/span][span style=\"color:#007700\"], [/span][span style=\"color:#0000BB\"]$totalRows_rs_photogal_imgs[/span][span style=\"color:#007700\"], [/span][span style=\"color:#0000BB\"]$queryString_rs_photogal_imgs[/span][span style=\"color:#007700\"]);

[/span][span style=\"color:#0000BB\"]?>

[/span]

<div id=\"photo\" style=\"position:absolute; width:370px; height:210px; z-index:5; left: 26px; top: 64px;\">

  [span style=\"color:#0000BB\"]<?php [/span][span style=\"color:#007700\"]do { [/span][span style=\"color:#0000BB\"]?>

[/span]  <img src=\"images/gallery/[span style=\"color:#0000BB\"]<?php [/span][span style=\"color:#007700\"]echo [/span][span style=\"color:#0000BB\"]$row_rs_photogal_imgs[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'filename\'[/span][span style=\"color:#007700\"]]; [/span][span style=\"color:#0000BB\"]?>[/span]\" alt=\"\" width=\"370\" height=\"210\" border=\"0\" />

  [span style=\"color:#0000BB\"]<?php [/span][span style=\"color:#007700\"]} while ([/span][span style=\"color:#0000BB\"]$row_rs_photogal_imgs [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]mysql_fetch_assoc[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$rs_photogal_imgs[/span][span style=\"color:#007700\"])); [/span][span style=\"color:#0000BB\"]?>

[/span]</div>

<div id=\"bkndPhotoGal\" style=\"position:absolute; width:422px; height:322px; z-index:1; top: 0px; left: 0px;\"><img src=\"images/backgrounds/bknd_photo_gal_pic.jpg\" alt=\"photos\" width=\"422\" height=\"322\" border=\"0\" /></div>

<div id=\"prev\" style=\"position:absolute; z-index:5; left: 26px; top: 281px; width: 145px; height: 22px;\"><a href=\"[span style=\"color:#0000BB\"]<?php printf[/span][span style=\"color:#007700\"]([/span][span style=\"color:#DD0000\"]\"%s?pageNum_rs_photogal_imgs=%d%s\"[/span][span style=\"color:#007700\"], [/span][span style=\"color:#0000BB\"]$currentPage[/span][span style=\"color:#007700\"], [/span][span style=\"color:#0000BB\"]max[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]0[/span][span style=\"color:#007700\"], [/span][span style=\"color:#0000BB\"]$pageNum_rs_photogal_imgs [/span][span style=\"color:#007700\"]- [/span][span style=\"color:#0000BB\"]1[/span][span style=\"color:#007700\"]), [/span][span style=\"color:#0000BB\"]$queryString_rs_photogal_imgs[/span][span style=\"color:#007700\"]); [/span][span style=\"color:#0000BB\"]?>[/span]\"><img src=\"images/buttons/photo_gal_prev.gif\" alt=\"prev\" width=\"145\" height=\"22\" border=\"0\" /></a></div>

<div id=\"next\" style=\"position:absolute; width:146px; height:22px; z-index:5; left: 249px; top: 281px;\"><a href=\"[span style=\"color:#0000BB\"]<?php printf[/span][span style=\"color:#007700\"]([/span][span style=\"color:#DD0000\"]\"%s?pageNum_rs_photogal_imgs=%d%s\"[/span][span style=\"color:#007700\"], [/span][span style=\"color:#0000BB\"]$currentPage[/span][span style=\"color:#007700\"], [/span][span style=\"color:#0000BB\"]min[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$totalPages_rs_photogal_imgs[/span][span style=\"color:#007700\"], [/span][span style=\"color:#0000BB\"]$pageNum_rs_photogal_imgs [/span][span style=\"color:#007700\"]+ [/span][span style=\"color:#0000BB\"]1[/span][span style=\"color:#007700\"]), [/span][span style=\"color:#0000BB\"]$queryString_rs_photogal_imgs[/span][span style=\"color:#007700\"]); [/span][span style=\"color:#0000BB\"]?>[/span]\"><img src=\"images/buttons/photo_gal_next.gif\" alt=\"next\" width=\"146\" height=\"22\" border=\"0\" /></a></div>

<div id=\"countbknd\" style=\"position:absolute; width:74px; height:22px; z-index:5; left: 173px; top: 281px;\"><img src=\"images/buttons/photo_gal_count.gif\" alt=\" \" width=\"74\" height=\"22\" border=\"0\" /></div>

<div id=\"count\" style=\"position:absolute; width:74px; z-index:6; left: 173px; top: 286px;\">

  <div class=\"white\" align=\"center\">[span style=\"color:#0000BB\"]<?php [/span][span style=\"color:#007700\"]echo ([/span][span style=\"color:#0000BB\"]$pageNum_rs_photogal_imgs [/span][span style=\"color:#007700\"]+ [/span][span style=\"color:#0000BB\"]1[/span][span style=\"color:#007700\"]) [/span][span style=\"color:#0000BB\"]?>[/span] of [span style=\"color:#0000BB\"]<?php [/span][span style=\"color:#007700\"]echo [/span][span style=\"color:#0000BB\"]$totalRows_rs_photogal_imgs ?>[/span] </div>

</div>

<div id=\"r1\" style=\"position:absolute; width:171px; height:136px; z-index:2; left: 422px; top: 0px;\">

  [span style=\"color:#0000BB\"]<?php [/span][span style=\"color:#007700\"]require_once([/span][span style=\"color:#DD0000\"]\'content/pod_webres.php\'[/span][span style=\"color:#007700\"]); [/span][span style=\"color:#0000BB\"]?>

[/span]</div>

<div id=\"r2\" style=\"position:absolute; width:171px; height:186px; z-index:6; left: 422px; top: 136px;\">

  [span style=\"color:#0000BB\"]<?php [/span][span style=\"color:#007700\"]require_once([/span][span style=\"color:#DD0000\"]\'content/pod_event_updates.php\'[/span][span style=\"color:#007700\"]); [/span][span style=\"color:#0000BB\"]?>

[/span]</div>

<div id=\"pulldown\" style=\"position:absolute; z-index:15; left: 17px; top: 33px;\">

  [span style=\"color:#0000BB\"]<?php [/span][span style=\"color:#007700\"]require_once([/span][span style=\"color:#DD0000\"]\'includes/gallery_navmenu.php\'[/span][span style=\"color:#007700\"]); [/span][span style=\"color:#0000BB\"]?>

[/span]</div>

[/span][!--PHP-Foot--][/div][!--PHP-EFoot--]

Any suggestions?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.