Help with if statement, when url var reaches record count.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
3dron
Forum Commoner
Posts: 40
Joined: Sat Feb 01, 2003 10:25 pm

Help with if statement, when url var reaches record count.

Post by 3dron »

THe following code increments my count variable in the url. But I can't get the conditional to work when the count reaches the record limit.

What am I missing?

if ($HTTP_GET_VARS['count'] == $totalRows_Record_count) {
echo"<META HTTP-EQUIV=\"refresh\" CONTENT=\"0; URL=lastpage.php\">";
}
else {
++$HTTP_GET_VARS['count'];
echo"<META HTTP-EQUIV=\"refresh\" CONTENT=\"0; URL=$HTTP_SERVER_VARS[PHP_SELF]?count=$HTTP_GET_VARS[count]\">";
}


Thanks for any help. You all have been invaluable.

ROn
User avatar
lazy_yogi
Forum Contributor
Posts: 243
Joined: Fri Jan 24, 2003 3:27 am

Post by lazy_yogi »

works for me

have you tried printing out .... to see if it contains anyting each time ?

Code: Select all

print $totalRows_Record_count;
3dron
Forum Commoner
Posts: 40
Joined: Sat Feb 01, 2003 10:25 pm

yes, my total records are printed out everytime

Post by 3dron »

My $totalRows_Record_count is printed out along with current record in the format

# of # 9 (i.e. 5 of 24)

But when the record reaches 24 it keeps going pas to 25 of 24 and beyond.

Am I missing some brackets, parenthesis, etc...
User avatar
gyardleydn
Forum Commoner
Posts: 27
Joined: Tue Dec 03, 2002 8:27 am

Re: Help with if statement, when url var reaches record coun

Post by gyardleydn »

3dron wrote:THe following code increments my count variable in the url. But I can't get the conditional to work when the count reaches the record limit
Try starting by hard typing $HTTP_GET_VARS['count'] and $totalRows_Record_count prior to your if statement. . If this successfully changes the branching you could backtrack using string gettype ( mixed var)

Code: Select all

$totalRows_Record_count = (integer)  $totalRows_Record_count;
$HTTP_GET_VARS&#1111;'count']  =  (integer) $HTTP_GET_VARS&#1111;'count'];
While this is unrelated to your problem and I don't want to be a harpy on this issue, you might consider using >= to protect yourself against malformed user input or a server error.
3dron
Forum Commoner
Posts: 40
Joined: Sat Feb 01, 2003 10:25 pm

Post by 3dron »

Thanks all. THis helped me track the problem down.

The count value was changing because of an update query, between the time when the page echoed my record_count and the time the 'if' statement occured.
Post Reply