PDA

View Full Version : detail page with navigation


boreas
08-06-2008, 06:50 AM
Hi

I want a page where users can click a thumbnail on my "thumbnails" page, then go to a detail page where they can see the full size image. But I also want navigation on this details page so users can go next or previous through all full size (repeat region showing 1 at a time) and don't have to return to the thumbnails page everytime.

I use something like this:

<a href="productdetail.php?id=4">Click here for product detail</a>

Then on the page productdetail.php something like this:

$query="SELECT * FROM products WHERE id=$id";

The problem is that the result is just 1 record.

Thank youv

edbr
08-06-2008, 07:29 AM
you need a do--while to loop through your records

boreas
08-06-2008, 07:35 AM
yes I know that, but query result is just 1 record.

edbr
08-06-2008, 07:35 AM
just re read it, you are using dreamweaver code for this?
(repeat region showing 1 at a time) not a repeat region then.
maybe better if you post the code

boreas
08-06-2008, 07:51 AM
scriptyes, I use Dreamweaver code:


$maxRows_rsDetaliu = 1;
$pageNum_rsDetaliu = 0;
if (isset($_GET['pageNum_rsDetaliu'])) {
$pageNum_rsDetaliu = $_GET['pageNum_rsDetaliu'];
}
$startRow_rsDetaliu = $pageNum_rsDetaliu * $maxRows_rsDetaliu;


$colname_rsDetaliu = "1";
if (isset($_GET['portret_id'])) {
$colname_rsDetaliu = $_GET['portret_id'];
}
mysql_select_db($database_adi, $adi);
$query_rsDetaliu = sprintf("SELECT * FROM portret WHERE portret.portret_id=%s", GetSQLValueString($colname_rsDetaliu, "int"));
$query_limit_rsDetaliu = sprintf("%s LIMIT %d, %d", $query_rsDetaliu, $startRow_rsDetaliu, $maxRows_rsDetaliu);
$rsDetaliu = mysql_query($query_limit_rsDetaliu, $adi) or die(mysql_error());
$row_rsDetaliu = mysql_fetch_assoc($rsDetaliu);


if (isset($_GET['totalRows_rsDetaliu'])) {
$totalRows_rsDetaliu = $_GET['totalRows_rsDetaliu'];
} else {
$all_rsDetaliu = mysql_query($query_rsDetaliu);
$totalRows_rsDetaliu = mysql_num_rows($all_rsDetaliu);
}
$totalPages_rsDetaliu = ceil($totalRows_rsDetaliu/$maxRows_rsDetaliu)-1;


$queryString_rsDetaliu = "";
if (!empty($_SERVER['QUERY_STRING'])) {
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_rsDetaliu") == false &&
stristr($param, "totalRows_rsDetaliu") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_rsDetaliu = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_rsDetaliu = sprintf("&totalRows_rsDetaliu=%d%s", $totalRows_rsDetaliu, $queryString_rsDetaliu);


?>

and there is the code for navigation buttons:

<?php if ($pageNum_rsDetaliu > 0) { // Show if not first page ?>
<a href="<?php printf("%s?pageNum_rsDetaliu=%d%s", $currentPage, max(0, $pageNum_rsDetaliu - 1), $queryString_rsDetaliu); ?>" class="nav">PREVIOUS</a>
<?php } // Show if not first page ?></a></td>
<td width="282" align="right" valign="bottom"><?php if ($pageNum_rsDetaliu < $totalPages_rsDetaliu) { // Show if not last page ?>
<a href="<?php printf("%s?pageNum_rsDetaliu=%d%s", $currentPage, min($totalPages_rsDetaliu, $pageNum_rsDetaliu + 1), $queryString_rsDetaliu); ?>" class="nav">MORE</a>
<?php } // Show if not last page ?></a>
__

edbr
08-06-2008, 09:36 AM
this is beyond my skills but are you getting any image?

boreas
08-06-2008, 02:51 PM
Yes. 1 :grin:

edbr
08-07-2008, 01:22 AM
ok wild stab here
i would make a page to display 1 record from your images and then add pagination to it. If that works then your problem lies with the link and dreamweaver not picking that up as a value.

i would also try
echo $currentPage to see what value that returned.

boreas
08-07-2008, 04:28 AM
thank you! :grin:

boreas
08-07-2008, 07:59 PM
I just find the solution: crate another 2 records, one for the previous record:

$rec=$_GET['id']

SELECT id FROM db WHERE id< $rec ORDER BY id DESC LIMIT 0, 1;

and another for the next:

SELECT id FROM db WHERE id> $rec ORDER BY id ASC LIMIT 0, 1;

Thank you :mrgreen: