Forums

PHP

This topic is locked

live navigation

Posted 09 Aug 2001 18:39:44
1
has voted
09 Aug 2001 18:39:44 Keith Slater posted:
Yea I know, you're sick of me...
I need some help with the live navigation stuff. When I put it in there it takes my repeat region stuff away.. Im not sure why. any help is welcomed

thanks

Keith Slater

Replies

Replied 10 Aug 2001 13:29:10
10 Aug 2001 13:29:10 Tim Green replied:
No, not sick of you <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>

I don't understand why this problem occurs, again, I don't have the same problem at all, and I use this set of behaviours probably more than any other.

It could well be another case of looking at the code. I'm wondering if you might have inserted some custom script or something else that could be breaking this ?

Tim Green

Extension & PHP TalkZone Manager
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>
Replied 10 Aug 2001 15:14:43
10 Aug 2001 15:14:43 Keith Slater replied:
Here is the code of the WHOLE page

&lt;?php


// Copyright (c) Interakt Online 2001
// www.interakt.ro/

require("./adodb/adodb.inc.php";
require("./Connections/CaricaturePHP.php";
?&gt;&lt;?php
// *** Restrict Access To Page: Grant or deny access to this page
$KT_authorizedUsers=" admin, user";
$KT_authFailedURL="permissions.php";
$KT_grantAccess=0;
session_start();
if (isset($HTTP_SESSION_VARS["KT_Username"])) {
if (false || !(isset($HTTP_SESSION_VARS["KT_UserAuthorization"])) || $HTTP_SESSION_VARS["KT_UserAuthorization"]=="" || strpos($KT_authorizedUsers, $HTTP_SESSION_VARS["KT_UserAuthorization"])) {
$KT_grantAccess = 1;
}
}
if (!$KT_grantAccess) {
$KT_qsChar = "?";
if (strpos($KT_authFailedURL, "?") $KT_qsChar = "&";
$KT_referrer = $PHP_SELF;
if (strlen($QUERY_STRING) &gt; 0) $KT_referrer .= "?" . $QUERY_STRING;
$KT_authFailedURL = $KT_authFailedURL . $KT_qsChar . "accessdenied=" . urlencode($KT_referrer);
header("Location: $KT_authFailedURL";
exit;
}
?&gt;&lt;?php
session_start();

// Copyright (c) Interakt Online 2001
// www.interakt.ro/

require("./adodb/adodb.inc.php";
require("./Connections/CaricaturePHP.php";
?&gt;&lt;?php
$Recordset1__MMColParam = "1";
if (isset($HTTP_SESSION_VARS["KT_Username"]))
{$Recordset1__MMColParam = $HTTP_SESSION_VARS["KT_Username"];}
?&gt;&lt;?php
if (isset($myDate)) {
$myDate=$CaricaturePHP-&gt;DBDate($myDate);
}
?&gt;&lt;?php
$Recordset1=$CaricaturePHP-&gt;Execute("SELECT * FROM GALLERY_1 WHERE USER_NAME = '" . ($Recordset1__MMColParam) . "'" or DIE($CaricaturePHP-&gt;ErrorMsg());
$Recordset1_numRows=0;
$Recordset1__totalRows=$Recordset1-&gt;RecordCount();
?&gt;&lt;?php
$Repeat1__numRows = -1;
$Repeat1__index= 0;
$Recordset1_numRows = $Recordset1_numRows + $Repeat1__numRows;
?&gt;
&lt;?php
// *** Recordset Stats, Move To Record, and Go To Record: declare stats variables

// set the record count
$Recordset1_total = $Recordset1-&gt;RecordCount();

// set the number of rows displayed on this page
if ($Recordset1_numRows &lt; 0) { // if repeat region set to all records
$Recordset1_numRows = $Recordset1_total;
} else if ($Recordset1_numRows == 0) { // if no repeat regions
$Recordset1_numRows = 1;
}

// set the first and last displayed record
$Recordset1_first = 1;
$Recordset1_last = $Recordset1_first + $Recordset1_numRows - 1;

// if we have the correct record count, check the other stats
if ($Recordset1_total != -1) {
$Recordset1_numRows = min($Recordset1_numRows, $Recordset1_total);
$Recordset1_first = min($Recordset1_first, $Recordset1_total);
$Recordset1_last = min($Recordset1_last, $Recordset1_total);
}
?&gt;
&lt;?php $MM_paramName = ""; ?&gt;
&lt;?php
// *** Move To Record and Go To Record: declare variables

$MM_rs = &$Recordset1;
$MM_rsCount = $Recordset1_total;
$MM_size = $Recordset1_numRows;
$MM_uniqueCol = "";
$MM_paramName = "";
$MM_offset = 0;
$MM_atTotal = false;
$MM_paramIsDefined = ($MM_paramName != "" && isset($$MM_paramName));
?&gt;
&lt;?php
// *** Move To Record: handle 'index' or 'offset' parameter

if (!$MM_paramIsDefined && $MM_rsCount != 0) {

// use index parameter if defined, otherwise use offset parameter
if(isset($index)){
$r = $index;
} else {
if(isset($offset)) {
$r = $offset;
} else {
$r = 0;
}
}
$MM_offset = $r;

// if we have a record count, check if we are past the end of the recordset
if ($MM_rsCount != -1) {
if ($MM_offset &gt;= $MM_rsCount || $MM_offset == -1) { // past end or move last
if (($MM_rsCount % $MM_size) != 0) { // last page not a full repeat region
$MM_offset = $MM_rsCount - ($MM_rsCount % $MM_size);
}
else {
$MM_offset = $MM_rsCount - $MM_size;
}
}
}

// move the cursor to the selected record
for ($i=0;!$MM_rs-&gt;EOF && ($i &lt; $MM_offset || $MM_offset == -1); $i++) {
$MM_rs-&gt;MoveNext();
}
if ($MM_rs-&gt;EOF) $MM_offset = $i; // set MM_offset to the last possible record
}
?&gt;
&lt;?php
// *** Move To Record: if we dont know the record count, check the display range

if ($MM_rsCount == -1) {

// walk to the end of the display range for this page
for ($i=$MM_offset; !$MM_rs-&gt;EOF && ($MM_size &lt; 0 || $i &lt; $MM_offset + $MM_size); $i++) {
$MM_rs-&gt;MoveNext();
}

// if we walked off the end of the recordset, set MM_rsCount and MM_size
if ($MM_rs-&gt;EOF) {
$MM_rsCount = $i;
if ($MM_size &lt; 0 || $MM_size &gt; $MM_rsCount) $MM_size = $MM_rsCount;
}

// if we walked off the end, set the offset based on page size
if ($MM_rs-&gt;EOF && !$MM_paramIsDefined) {
if (($MM_rsCount % $MM_size) != 0) { // last page not a full repeat region
$MM_offset = $MM_rsCount - ($MM_rsCount % $MM_size);
} else {
$MM_offset = $MM_rsCount - $MM_size;
}
}

// reset the cursor to the beginning
$MM_rs-&gt;MoveFirst();

// move the cursor to the selected record
for ($i=0; !$MM_rs-&gt;EOF && $i &lt; $MM_offset; $i++) {
$MM_rs-&gt;MoveNext();
}
}
?&gt;
&lt;?php
// *** Move To Record: update recordset stats

// set the first and last displayed record
$Recordset1_first = $MM_offset + 1;
$Recordset1_last = $MM_offset + $MM_size;
if ($MM_rsCount != -1) {
$Recordset1_first = $Recordset1_first&lt;$MM_rsCount?$Recordset1_first:$MM_rsCount;
$Recordset1_last = $Recordset1_last&lt;$MM_rsCount?$Recordset1_last:$MM_rsCount;
}

// set the boolean used by hide region to check if we are on the last record
$MM_atTotal = ($MM_rsCount != -1 && $MM_offset + $MM_size &gt;= $MM_rsCount);
?&gt;
&lt;?php
// *** Go To Record and Move To Record: create strings for maintaining URL and Form parameters

// create the list of parameters which should not be maintained
$MM_removeList = "&index=";
if ($MM_paramName != "" $MM_removeList .= "&".strtolower($MM_paramName)."=";
$MM_keepURL="";
$MM_keepForm="";
$MM_keepBoth="";
$MM_keepNone="";

// add the URL parameters to the MM_keepURL string
reset ($HTTP_GET_VARS);
while (list ($key, $val) = each ($HTTP_GET_VARS)) {
$nextItem = "&".strtolower($key)."=";
if (!stristr($MM_removeList, $nextItem)) {
$MM_keepURL .= "&".$key."=".urlencode($val);
}
}

// add the URL parameters to the MM_keepURL string
if(isset($HTTP_POST_VARS)){
reset ($HTTP_POST_VARS);
while (list ($key, $val) = each ($HTTP_POST_VARS)) {
$nextItem = "&".strtolower($key)."=";
if (!stristr($MM_removeList, $nextItem)) {
$MM_keepForm .= "&".$key."=".urlencode($val);
}
}
}

// create the Form + URL string and remove the intial '&' from each of the strings
$MM_keepBoth = $MM_keepURL."&".$MM_keepForm;
if (strlen($MM_keepBoth) &gt; 0) $MM_keepBoth = substr($MM_keepBoth, 1);
if (strlen($MM_keepURL) &gt; 0) $MM_keepURL = substr($MM_keepURL, 1);
if (strlen($MM_keepForm) &gt; 0) $MM_keepForm = substr($MM_keepForm, 1);
?&gt;
&lt;?php
// *** Move To Record: set the strings for the first, last, next, and previous links

$MM_moveFirst="";
$MM_moveLast="";
$MM_moveNext="";
$MM_movePrev="";
$MM_keepMove = $MM_keepBoth; // keep both Form and URL parameters for moves
$MM_moveParam = "index";

// if the page has a repeated region, remove 'offset' from the maintained parameters
if ($MM_size &gt; 1) {
$MM_moveParam = "offset";
if (strlen($MM_keepMove)&gt; 0) {
$params = explode("&", $MM_keepMove);
$MM_keepMove = "";
for ($i=0; $i &lt; sizeof($params); $i++) {
list($nextItem) = explode("=", $params[$i]);
if (strtolower($nextItem) != $MM_moveParam) {
$MM_keepMove.="&".$params[$i];
}
}
if (strlen($MM_keepMove) &gt; 0) $MM_keepMove = substr($MM_keepMove, 1);
}
}

// set the strings for the move to links
if (strlen($MM_keepMove) &gt; 0) $MM_keepMove.="&";
$urlStr = $PHP_SELF."?".$MM_keepMove.$MM_moveParam."=";
$MM_moveFirst = $urlStr."0";
$MM_moveLast = $urlStr."-1";
$MM_moveNext = $urlStr.($MM_offset + $MM_size);
$MM_movePrev = $urlStr.(max($MM_offset - $MM_size,0));
?&gt;
&lt;?php
// *** Logout the current user. false
$KT_Logout = $PHP_SELF . "?KT_Logoutnow=1";
if ($KT_Logoutnow=="1" {
session_start();
session_unregister("KT_Username";
$KT_logoutRedirectPage = "keith/caricaturephp/index.php?id=Studio&id2=Convention&id3=Miscellaneous&id4=Published&id5=Celebrity&id6=Showcase";
// redirect with URL parameters (remove the "KT_Logoutnow" query param).
if ($KT_logoutRedirectPage == "" $KT_logoutRedirectPage = $PHP_SELF;
if (!strpos($KT_logoutRedirectPage, "?" && $QUERY_STRING != "" {
$KT_newQS = "?";
reset ($HTTP_GET_VARS);
while (list ($key, $val) = each ($HTTP_GET_VARS)) {
if($key != "KT_Logoutnow"{
if (strlen($KT_newQS) &gt; 1) $KT_newQS .= "&";
$KT_newQS .= $key . "=" . urlencode($val);
}
}
if (strlen($KT_newQS) &gt; 1) $KT_logoutRedirectPage .= $KT_newQS;
}
header("Location: $KT_logoutRedirectPage";
exit;
}
?&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Untitled Document&lt;/title&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"&gt;
&lt;/head&gt;
&lt;body bgcolor="#FFFFFF" text="#000000"&gt;
&lt;table width="740" border="0" align="center"&gt;
&lt;tr&gt;
&lt;td height="92"&gt;
&lt;div align="center"&gt;&lt;a href="www.wordprosys.com"&gt;&lt;img src="WPS1.gif" width="108" height="108" border="0"&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td valign="middle" height="92"&gt;
&lt;div align="center"&gt;&lt;br&gt;
&lt;img src="caricathead3%20copy.gif" width="356" height="64"&gt;&lt;br&gt;
&lt;/div&gt;
&lt;table width="302" border="0" align="center"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;div align="center"&gt;&lt;a href="index.php?id=Studio&id2=Convention&id3=Miscellaneous&id4=Published&id5=Celebrity&id6=Showcase"&gt;Forum&lt;/a&gt;
- &lt;a href="admin.php"&gt;Main&lt;/a&gt; - &lt;font size="3"&gt;&lt;a href="&lt;?php echo $KT_Logout?&gt;"&gt;Logout&lt;/a&gt;&lt;/font&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/td&gt;
&lt;td height="92"&gt;
&lt;div align="center"&gt;&lt;a href="www.caricature.org"&gt;&lt;img src="ncnlogosmall.jpg" width="100" height="72" border="0"&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan="3"&gt;
&lt;div align="center"&gt;&lt;br&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" colspan="3" height="476"&gt;
&lt;p align="center"&gt;&lt;b&gt;&lt;a href="addcar.php"&gt;Insert a Caricature!&lt;/a&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p align="center"&gt;&lt;b&gt;&lt;a href="addcar.php"&gt;&lt;br&gt;
&lt;/a&gt;Current Gallery:&lt;/b&gt;&lt;br&gt;
&lt;/p&gt;
&lt;form name="form1" action=""&gt;
&lt;div align="center"&gt;&lt;br&gt;
&lt;table width="425" border="0" align="center"&gt;
&lt;?php while (($Repeat1__numRows-- != 0) && (!$Recordset1-&gt;EOF))
{
?&gt;
&lt;tr&gt;
&lt;?php
$theLoop=0;
while (($theLoop &lt;3) && (!$Recordset1-&gt;EOF)){
$theLoop++;
?&gt;
&lt;td&gt;
&lt;div align="center"&gt;
&lt;table width="250" border="0"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;div align="center"&gt; &lt;b&gt;
&lt;?php echo $Recordset1-&gt;Fields("CATEGORY"?&gt;
&lt;/b&gt; &lt;br&gt;
&lt;img src="images/&lt;?php echo $Recordset1-&gt;Fields("PICTURE_NAME"?&gt;" width="150" height="150"&gt;&lt;br&gt;
&lt;?php echo $Recordset1-&gt;Fields("INFO"?&gt;
&lt;br&gt;
&lt;input type="button" name="edit" value="Edit" onClick="location.href='edit.php?edit=&lt;?php echo $Recordset1-&gt;Fields("PICTURE_NAME"?&gt;'"&gt;
&lt;input type="button" name="radiobutton" onClick="location.href='delcar2.php?radiobutton=&lt;?php echo $Recordset1-&gt;Fields("PICTURE_NAME"?&gt;'" value="Delete" label="Delete"&gt;
&lt;br&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;?php
$Recordset1-&gt;MoveNext();
}
?&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;?php
$Repeat1__index++;
$Recordset1-&gt;MoveNext();
}
?&gt;
&lt;/table&gt;
&lt;br&gt;
&lt;/div&gt;
&lt;/form&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" colspan="3"&gt;
&lt;div align="center"&gt;
&lt;table border="0" width="50%" align="center"&gt;
&lt;tr&gt;
&lt;td width="23%" align="center"&gt;
&lt;?php if ($MM_offset != 0) { ?&gt;
&lt;a href="&lt;?php echo $MM_moveFirst?&gt;"&gt;&lt;img src="First.gif" border=0&gt;&lt;/a&gt;
&lt;?php } // end $MM_offset != 0 ?&gt;
&lt;/td&gt;
&lt;td width="31%" align="center"&gt;
&lt;?php if ($MM_offset != 0) { ?&gt;
&lt;a href="&lt;?php echo $MM_movePrev?&gt;"&gt;&lt;img src="Previous.gif" border=0&gt;&lt;/a&gt;
&lt;?php } // end $MM_offset != 0 ?&gt;
&lt;/td&gt;
&lt;td width="23%" align="center"&gt;
&lt;?php if (!$MM_atTotal) { ?&gt;
&lt;a href="&lt;?php echo $MM_moveNext?&gt;"&gt;&lt;img src="Next.gif" border=0&gt;&lt;/a&gt;
&lt;?php } // end !$MM_atTotal ?&gt;
&lt;/td&gt;
&lt;td width="23%" align="center"&gt;
&lt;?php if (!$MM_atTotal) { ?&gt;
&lt;a href="&lt;?php echo $MM_moveLast?&gt;"&gt;&lt;img src="Last.gif" border=0&gt;&lt;/a&gt;
&lt;?php } // end !$MM_atTotal ?&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/body&gt;
&lt;/html&gt;
&lt;?php
$Recordset1-&gt;Close();
?&gt;


Keith Slater
Replied 14 Aug 2001 15:04:38
14 Aug 2001 15:04:38 Keith Slater replied:
Does anyone know this answer please...

Keith Slater
Replied 14 Aug 2001 15:38:17
14 Aug 2001 15:38:17 Tim Green replied:
Keith,

You really should read the UD Documentation. This problem is actually covered in there.

You have created a repeat region, except you haven't limited the options. So, in your situation you would create a repeat region of 12 items. This then allows the Show Region behaviours to work.

If you create a repeat region of all records, and then don't use all of the recordset the excess information is dumped, and the rest of the code doesn't come into play.

BTW: This is called Recordset Navigation, not Live Navigation. Live Navigation implies something else, but this is indeed covered in the UD docs, and there already exists a vast amount of help and documentation on this subject.

I would also recommend that you remove some of your manual editing.

I see you have manually added a session_start() to one of the require blocks. This block has now been duplicated and you run the risk of negating your session_start() command because the same command is issued earlier in the document.

The session_start() command is automatically added when you restrict access to a page.

The other problem I see immediately is with your date creation block :-

&lt;?php
if (isset($myDate)) {
$myDate=$CaricaturePHP-&gt;DBDate($myDate);
}
?&gt;

Which is saying if myDate exists set it to the current date.

It should be :-

&lt;?php
if (!isset($myDate)) {
$myDate=$CaricaturePHP-&gt;DBDate($myDate);
}
?&gt;

Which allows you to set the date if it isn't already set.

Anyway, I think this should get you moving in the right direction.

Tim Green

Extension & PHP TalkZone Manager
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>
Replied 14 Aug 2001 18:12:14
14 Aug 2001 18:12:14 Keith Slater replied:
ok I went a started a brand new page. I have 34 records of pictures that its supposed to load. When I try to do it it loads the first 10 like it should. you hit next and it only shows 4 then you hit next and it shows none. its not filtered or sorted at all. heres the script

&lt;?php


// Copyright (c) Interakt Online 2001
// www.interakt.ro/

require("./adodb/adodb.inc.php";
require("./Connections/CaricaturePHP.php";
?&gt;&lt;?php
// *** Restrict Access To Page: Grant or deny access to this page
$KT_authorizedUsers=" admin, user";
$KT_authFailedURL="permissions.php";
$KT_grantAccess=0;
session_start();
if (isset($HTTP_SESSION_VARS["KT_Username"])) {
if (false || !(isset($HTTP_SESSION_VARS["KT_UserAuthorization"])) || $HTTP_SESSION_VARS["KT_UserAuthorization"]=="" || strpos($KT_authorizedUsers, $HTTP_SESSION_VARS["KT_UserAuthorization"])) {
$KT_grantAccess = 1;
}
}
if (!$KT_grantAccess) {
$KT_qsChar = "?";
if (strpos($KT_authFailedURL, "?") $KT_qsChar = "&";
$KT_referrer = $PHP_SELF;
if (strlen($QUERY_STRING) &gt; 0) $KT_referrer .= "?" . $QUERY_STRING;
$KT_authFailedURL = $KT_authFailedURL . $KT_qsChar . "accessdenied=" . urlencode($KT_referrer);
header("Location: $KT_authFailedURL";
exit;
}
?&gt;&lt;?php
$Recordset1__MMColParam = "1";
if (isset($HTTP_SESSION_VARS["KT_Username"]))
{$Recordset1__MMColParam = $HTTP_SESSION_VARS["KT_Username"];}
?&gt;&lt;?php
$Recordset1=$CaricaturePHP-&gt;Execute("SELECT * FROM GALLERY_1 WHERE USER_NAME = '" . ($Recordset1__MMColParam) . "' ORDER BY IDNO DESC" or DIE($CaricaturePHP-&gt;ErrorMsg());
$Recordset1_numRows=0;
$Recordset1__totalRows=$Recordset1-&gt;RecordCount();
?&gt;&lt;?php
$Repeat1__numRows = 8;
$Repeat1__index= 0;
$Recordset1_numRows = $Recordset1_numRows + $Repeat1__numRows;
?&gt;&lt;?php
// *** Recordset Stats, Move To Record, and Go To Record: declare stats variables

// set the record count
$Recordset1_total = $Recordset1-&gt;RecordCount();

// set the number of rows displayed on this page
if ($Recordset1_numRows &lt; 0) { // if repeat region set to all records
$Recordset1_numRows = $Recordset1_total;
} else if ($Recordset1_numRows == 0) { // if no repeat regions
$Recordset1_numRows = 1;
}

// set the first and last displayed record
$Recordset1_first = 1;
$Recordset1_last = $Recordset1_first + $Recordset1_numRows - 1;

// if we have the correct record count, check the other stats
if ($Recordset1_total != -1) {
$Recordset1_numRows = min($Recordset1_numRows, $Recordset1_total);
$Recordset1_first = min($Recordset1_first, $Recordset1_total);
$Recordset1_last = min($Recordset1_last, $Recordset1_total);
}
?&gt;&lt;?php $MM_paramName = ""; ?&gt;&lt;?php
// *** Move To Record and Go To Record: declare variables

$MM_rs = &$Recordset1;
$MM_rsCount = $Recordset1_total;
$MM_size = $Recordset1_numRows;
$MM_uniqueCol = "";
$MM_paramName = "";
$MM_offset = 0;
$MM_atTotal = false;
$MM_paramIsDefined = ($MM_paramName != "" && isset($$MM_paramName));
?&gt;&lt;?php
// *** Move To Record: handle 'index' or 'offset' parameter

if (!$MM_paramIsDefined && $MM_rsCount != 0) {

// use index parameter if defined, otherwise use offset parameter
if(isset($index)){
$r = $index;
} else {
if(isset($offset)) {
$r = $offset;
} else {
$r = 0;
}
}
$MM_offset = $r;

// if we have a record count, check if we are past the end of the recordset
if ($MM_rsCount != -1) {
if ($MM_offset &gt;= $MM_rsCount || $MM_offset == -1) { // past end or move last
if (($MM_rsCount % $MM_size) != 0) { // last page not a full repeat region
$MM_offset = $MM_rsCount - ($MM_rsCount % $MM_size);
}
else {
$MM_offset = $MM_rsCount - $MM_size;
}
}
}

// move the cursor to the selected record
for ($i=0;!$MM_rs-&gt;EOF && ($i &lt; $MM_offset || $MM_offset == -1); $i++) {
$MM_rs-&gt;MoveNext();
}
if ($MM_rs-&gt;EOF) $MM_offset = $i; // set MM_offset to the last possible record
}
?&gt;&lt;?php
// *** Move To Record: if we dont know the record count, check the display range

if ($MM_rsCount == -1) {

// walk to the end of the display range for this page
for ($i=$MM_offset; !$MM_rs-&gt;EOF && ($MM_size &lt; 0 || $i &lt; $MM_offset + $MM_size); $i++) {
$MM_rs-&gt;MoveNext();
}

// if we walked off the end of the recordset, set MM_rsCount and MM_size
if ($MM_rs-&gt;EOF) {
$MM_rsCount = $i;
if ($MM_size &lt; 0 || $MM_size &gt; $MM_rsCount) $MM_size = $MM_rsCount;
}

// if we walked off the end, set the offset based on page size
if ($MM_rs-&gt;EOF && !$MM_paramIsDefined) {
if (($MM_rsCount % $MM_size) != 0) { // last page not a full repeat region
$MM_offset = $MM_rsCount - ($MM_rsCount % $MM_size);
} else {
$MM_offset = $MM_rsCount - $MM_size;
}
}

// reset the cursor to the beginning
$MM_rs-&gt;MoveFirst();

// move the cursor to the selected record
for ($i=0; !$MM_rs-&gt;EOF && $i &lt; $MM_offset; $i++) {
$MM_rs-&gt;MoveNext();
}
}
?&gt;&lt;?php
// *** Move To Record: update recordset stats

// set the first and last displayed record
$Recordset1_first = $MM_offset + 1;
$Recordset1_last = $MM_offset + $MM_size;
if ($MM_rsCount != -1) {
$Recordset1_first = $Recordset1_first&lt;$MM_rsCount?$Recordset1_first:$MM_rsCount;
$Recordset1_last = $Recordset1_last&lt;$MM_rsCount?$Recordset1_last:$MM_rsCount;
}

// set the boolean used by hide region to check if we are on the last record
$MM_atTotal = ($MM_rsCount != -1 && $MM_offset + $MM_size &gt;= $MM_rsCount);
?&gt;&lt;?php
// *** Go To Record and Move To Record: create strings for maintaining URL and Form parameters

// create the list of parameters which should not be maintained
$MM_removeList = "&index=";
if ($MM_paramName != "" $MM_removeList .= "&".strtolower($MM_paramName)."=";
$MM_keepURL="";
$MM_keepForm="";
$MM_keepBoth="";
$MM_keepNone="";

// add the URL parameters to the MM_keepURL string
reset ($HTTP_GET_VARS);
while (list ($key, $val) = each ($HTTP_GET_VARS)) {
$nextItem = "&".strtolower($key)."=";
if (!stristr($MM_removeList, $nextItem)) {
$MM_keepURL .= "&".$key."=".urlencode($val);
}
}

// add the URL parameters to the MM_keepURL string
if(isset($HTTP_POST_VARS)){
reset ($HTTP_POST_VARS);
while (list ($key, $val) = each ($HTTP_POST_VARS)) {
$nextItem = "&".strtolower($key)."=";
if (!stristr($MM_removeList, $nextItem)) {
$MM_keepForm .= "&".$key."=".urlencode($val);
}
}
}

// create the Form + URL string and remove the intial '&' from each of the strings
$MM_keepBoth = $MM_keepURL."&".$MM_keepForm;
if (strlen($MM_keepBoth) &gt; 0) $MM_keepBoth = substr($MM_keepBoth, 1);
if (strlen($MM_keepURL) &gt; 0) $MM_keepURL = substr($MM_keepURL, 1);
if (strlen($MM_keepForm) &gt; 0) $MM_keepForm = substr($MM_keepForm, 1);
?&gt;&lt;?php
// *** Move To Record: set the strings for the first, last, next, and previous links

$MM_moveFirst="";
$MM_moveLast="";
$MM_moveNext="";
$MM_movePrev="";
$MM_keepMove = $MM_keepBoth; // keep both Form and URL parameters for moves
$MM_moveParam = "index";

// if the page has a repeated region, remove 'offset' from the maintained parameters
if ($MM_size &gt; 1) {
$MM_moveParam = "offset";
if (strlen($MM_keepMove)&gt; 0) {
$params = explode("&", $MM_keepMove);
$MM_keepMove = "";
for ($i=0; $i &lt; sizeof($params); $i++) {
list($nextItem) = explode("=", $params[$i]);
if (strtolower($nextItem) != $MM_moveParam) {
$MM_keepMove.="&".$params[$i];
}
}
if (strlen($MM_keepMove) &gt; 0) $MM_keepMove = substr($MM_keepMove, 1);
}
}

// set the strings for the move to links
if (strlen($MM_keepMove) &gt; 0) $MM_keepMove.="&";
$urlStr = $PHP_SELF."?".$MM_keepMove.$MM_moveParam."=";
$MM_moveFirst = $urlStr."0";
$MM_moveLast = $urlStr."-1";
$MM_moveNext = $urlStr.($MM_offset + $MM_size);
$MM_movePrev = $urlStr.(max($MM_offset - $MM_size,0));
?&gt;&lt;?php
// *** Logout the current user. false
$KT_Logout = $PHP_SELF . "?KT_Logoutnow=1";
if ($KT_Logoutnow=="1" {
session_start();
session_unregister("KT_Username";
$KT_logoutRedirectPage = "index.php?id=Studio&id2=Convention&id3=Miscellaneous&id4=Published&id5=Celebrity&id6=Showcase";
// redirect with URL parameters (remove the "KT_Logoutnow" query param).
if ($KT_logoutRedirectPage == "" $KT_logoutRedirectPage = $PHP_SELF;
if (!strpos($KT_logoutRedirectPage, "?" && $QUERY_STRING != "" {
$KT_newQS = "?";
reset ($HTTP_GET_VARS);
while (list ($key, $val) = each ($HTTP_GET_VARS)) {
if($key != "KT_Logoutnow"{
if (strlen($KT_newQS) &gt; 1) $KT_newQS .= "&";
$KT_newQS .= $key . "=" . urlencode($val);
}
}
if (strlen($KT_newQS) &gt; 1) $KT_logoutRedirectPage .= $KT_newQS;
}
header("Location: $KT_logoutRedirectPage";
exit;
}
?&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Caricature Forum - Gallery&lt;/title&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"&gt;
&lt;/head&gt;
&lt;body bgcolor="#FFFFFF" text="#000000"&gt;
&lt;table width="740" border="0" align="center"&gt;
&lt;tr&gt;
&lt;td height="92" width="139"&gt;
&lt;div align="center"&gt;&lt;a href="www.wordprosys.com"&gt;&lt;img src="WPS1.gif" width="108" height="108" border="0"&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;td valign="middle" height="92" width="459"&gt;
&lt;div align="center"&gt;&lt;br&gt;
&lt;img src="caricathead3%20copy.gif" width="356" height="64"&gt;&lt;br&gt;
&lt;/div&gt;
&lt;table width="302" border="0" align="center"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;div align="center"&gt;&lt;a href="index.php?id=Studio&id2=Convention&id3=Miscellaneous&id4=Published&id5=Celebrity&id6=Showcase"&gt;Forum&lt;/a&gt;
- &lt;a href="admin.php"&gt;Main&lt;/a&gt; - &lt;font size="3"&gt;&lt;a href="&lt;?php echo $KT_Logout?&gt;"&gt;Logout&lt;/a&gt;&lt;/font&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/td&gt;
&lt;td height="92" width="128"&gt;
&lt;div align="center"&gt;&lt;a href="www.caricature.org"&gt;&lt;img src="ncnlogosmall.jpg" width="100" height="72" border="0"&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan="3"&gt;
&lt;div align="center"&gt; &lt;br&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" colspan="3" height="476"&gt;
&lt;p align="center"&gt;&lt;b&gt;&lt;a href="addcar.php"&gt;Insert a Caricature!&lt;/a&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p align="center"&gt;&lt;b&gt;&lt;a href="addcar.php"&gt;&lt;br&gt;
&lt;/a&gt;Current Gallery:&lt;/b&gt;&lt;br&gt;
&lt;/p&gt;
&lt;form name="form1" action=""&gt;
&lt;div align="center"&gt;&lt;br&gt;
&lt;table width="425" border="0" align="center"&gt;
&lt;?php while (($Repeat1__numRows-- != 0) && (!$Recordset1-&gt;EOF))
{
?&gt;
&lt;tr&gt;
&lt;?php
$theLoop=0;
while (($theLoop &lt;2) && (!$Recordset1-&gt;EOF)){
$theLoop++;
?&gt;
&lt;td&gt;
&lt;div align="center"&gt;
&lt;table width="250" border="0"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;div align="center"&gt; &lt;b&gt;
&lt;?php echo $Recordset1-&gt;Fields("CATEGORY"?&gt;
&lt;/b&gt; &lt;br&gt;
&lt;img src="images/&lt;?php echo $Recordset1-&gt;Fields("PICTURE_NAME"?&gt;" width="150" height="150"&gt;&lt;br&gt;
&lt;?php echo $Recordset1-&gt;Fields("INFO"?&gt;
&lt;br&gt;
&lt;input type="button" name="edit" value="Edit" onClick="location.href='edit.php?edit=&lt;?php echo $Recordset1-&gt;Fields("PICTURE_NAME"?&gt;'"&gt;
&lt;input type="button" name="radiobutton" onClick="location.href='delcar2.php?radiobutton=&lt;?php echo $Recordset1-&gt;Fields("PICTURE_NAME"?&gt;'" value="Delete" label="Delete"&gt;
&lt;br&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;?php
$Recordset1-&gt;MoveNext();
}
?&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;?php
$Repeat1__index++;
$Recordset1-&gt;MoveNext();
}
?&gt;
&lt;/table&gt;
&lt;br&gt;
&lt;/div&gt;
&lt;/form&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" colspan="3"&gt;
&lt;div align="center"&gt;
&lt;table border="0" width="50%" align="center"&gt;
&lt;tr&gt;
&lt;td width="23%" align="center"&gt;
&lt;?php if ($MM_offset != 0) { ?&gt;
&lt;a href="&lt;?php echo $MM_moveFirst?&gt;"&gt;First&lt;/a&gt;
&lt;?php } // end $MM_offset != 0 ?&gt;
&lt;/td&gt;
&lt;td width="31%" align="center"&gt;
&lt;?php if ($MM_offset != 0) { ?&gt;
&lt;a href="&lt;?php echo $MM_movePrev?&gt;"&gt;Previous&lt;/a&gt;
&lt;?php } // end $MM_offset != 0 ?&gt;
&lt;/td&gt;
&lt;td width="23%" align="center"&gt;
&lt;?php if (!$MM_atTotal) { ?&gt;
&lt;a href="&lt;?php echo $MM_moveNext?&gt;"&gt;Next&lt;/a&gt;
&lt;?php } // end !$MM_atTotal ?&gt;
&lt;/td&gt;
&lt;td width="23%" align="center"&gt;
&lt;?php if (!$MM_atTotal) { ?&gt;
&lt;a href="&lt;?php echo $MM_moveLast?&gt;"&gt;Last&lt;/a&gt;
&lt;?php } // end !$MM_atTotal ?&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/body&gt;
&lt;/html&gt;
&lt;?php
$Recordset1-&gt;Close();
?&gt;



thanks again tim

Keith Slater
Replied 14 Aug 2001 19:36:13
14 Aug 2001 19:36:13 Keith Slater replied:
ok I got the navigation stuff figured out it just doesnt load all my pictures for some reason still. its the same script as above

thanks

Keith Slater
Replied 14 Aug 2001 20:43:56
14 Aug 2001 20:43:56 Tim Green replied:
If it doesn't load all your pictures, even though you define a path, and use the result of a column as the filename, then you are going to have to check that every filename is correct, that the path is correct, and that the case of each filename is correct.

Please do not post any more code listings to this thread, which is already impossible to read.

It is likely that if problems persist, that it has something to do with the script that recurs across the page. It is for this reason that the Horizontal Looper was created.

I would suggest that if you still have problems that you strip the code back down to basics, then apply the standard repeat region alone, and see what kind of result you get, and then build on that.

Tim Green

Extension & PHP TalkZone Manager
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>
Replied 14 Aug 2001 23:39:23
14 Aug 2001 23:39:23 Keith Slater replied:
ok sorry about the posts. I figured out what my script is doing. I have 34 pictures. The repeat region shows 10 on a page. I found out that it only shows 14. 20 less than what it should. So I printed out all the pictures that it should show. And I circled the pictures that it shows. I realized that it skips my first 10 pictures. Then shows the next 10 pictures on the page. Then I saw it skipped the next 10 pictures and displays teh next 4 on the next page. So for some reason it wants to skip 10 pictures on each page that is displayed. Its kinda weird. Do you have any ideas of why this might be happening tim??

thanks again

Keith Slater
Replied 15 Aug 2001 01:18:25
15 Aug 2001 01:18:25 Tim Green replied:
Keith, I don't mind about the posts at all ! I was just a little concerned about the length of some of the code.

Anyway, I've hacked around a bit of Tom Muck's Horizontal Looper code, and this works fine for me, hopefully it should work for you too :-

&lt;form name="form1" action=""&gt;
&lt;div align="center"&gt;&lt;br&gt;
&lt;table width="425" border="0" align="center"&gt;
&lt;?php
$startrw=0;
$endrw=$Repeat1__index;
$numberColumns=2;
$numrows=ceil($Repeat1__numRows/$numberColumns);
while(($numrows-- !=0) && (!$Recordset1-&gt;EOF)) {
$startrw=$endrw + 1;
$endrw = $endrw + $numberColumns;
?&gt;
&lt;tr&gt;
&lt;?php while (($startrw &lt;= $endrw) && (!$Recordset1-&gt;EOF)) { ?&gt;
&lt;td&gt;
&lt;div align="center"&gt;
&lt;table width="250" border="0"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;div align="center"&gt; &lt;b&gt;
&lt;?php echo $Recordset1-&gt;Fields("CATEGORY"?&gt;
&lt;/b&gt; &lt;br&gt;
&lt;img src="images/&lt;?php echo $Recordset1-&gt;Fields("PICTURE_NAME"?&gt;" width="150" height="150"&gt;&lt;br&gt;
&lt;?php echo $Recordset1-&gt;Fields("INFO"?&gt;
&lt;br&gt;
&lt;input type="button" name="edit" value="Edit" onClick="location.href='edit.php?edit=&lt;?php echo $Recordset1-&gt;Fields("PICTURE_NAME"?&gt;'"&gt;
&lt;input type="button" name="radiobutton" onClick="location.href='delcar2.php?radiobutton=&lt;?php echo $Recordset1-&gt;Fields("PICTURE_NAME"?&gt;'" value="Delete" label="Delete"&gt;
&lt;br&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;?php
$startrw++;
$Recordset1-&gt;MoveNext();
}
?&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;?php
$Repeat1__index++;
$Recordset1-&gt;MoveNext();
}
?&gt;
&lt;/table&gt;
&lt;br&gt;
&lt;/div&gt;
&lt;/form&gt;

I've just replaced the looper code I gave you earlier for something a little more robust.

Hope this helps


Tim Green

Extension & PHP TalkZone Manager
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>
Replied 15 Aug 2001 15:11:57
15 Aug 2001 15:11:57 Keith Slater replied:
Hey that script works and its cool. But as soon as I add recordset navigation to it it does the skipping 10 thing just as above. Theirs gotta be something Im missing here. Phakt keeps on putting something in my script and I cant find it.

Keith Slater
Replied 15 Aug 2001 16:58:34
15 Aug 2001 16:58:34 Tim Green replied:
That's because the recordset navigation is breaking the code you just entered.

Try inserting the navigation, and then adding the fixed code I sent to you. It should work just fine (it did for me).

Tim Green

Extension & PHP TalkZone Manager
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>

Reply to this topic