Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Modules
Author Message
rogue3
Regular
Regular



Joined: Jul 02, 2009
Posts: 71

PostPosted: Wed Sep 09, 2009 1:22 pm Reply with quote

I'm trying to alter the code so that when an admin visits a review page it doesn't count against the hit counter. I assume if I modify this statement:

Code:
    if (($page == 1) OR ($page == "")) {

   $db->sql_query("UPDATE ".$prefix."_jreviews SET hits=hits+1 WHERE id='$id'");


and add maybe a 'if admin' statement with another line of code that has hits+0 or something that might work, but I'm having trouble figuring out the proper way to code it. Can anyone help?


Last edited by rogue3 on Sun Sep 13, 2009 7:00 am; edited 1 time in total 
View user's profile Send private message
evaders99
Former Moderator in Good Standing



Joined: Apr 30, 2004
Posts: 3221

PostPosted: Wed Sep 09, 2009 7:29 pm Reply with quote

Code:


if (!is_admin($admin)) {
$db->sql_query("UPDATE ".$prefix."_jreviews SET hits=hits+1 WHERE id='$id'");
}


Of course, you'll need to make sure $admin is in scope to use

_________________
- Star Wars Rebellion Network -

Need help? Nuke Patched Core, Coding Services, Webmaster Services 
View user's profile Send private message Visit poster's website
rogue3







PostPosted: Wed Sep 09, 2009 8:10 pm Reply with quote

Wouldn't that make only the admin apply hits? Would I need an else statement in there?

I tried this, but it didn't seem to do anything:

Code:
if (!is_admin($admin)) { 

$db->sql_query("UPDATE ".$prefix."_jreviews SET hits=hits+0 WHERE id='$id'");
}
    else if (($page == 1) OR ($page == "")) {
   $db->sql_query("UPDATE ".$prefix."_jreviews SET hits=hits+1 WHERE id='$id'");
    }
 
Palbin
Site Admin



Joined: Mar 30, 2006
Posts: 2583
Location: Pittsburgh, Pennsylvania

PostPosted: Wed Sep 09, 2009 9:18 pm Reply with quote

That statement says if NOT an admin then do the update. The "!" makes it "if not". The else statement you added will make it apply to all cases. Well I'm not sure what the $page variable does, but you should see my point now.

_________________
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan. 
View user's profile Send private message
rogue3







PostPosted: Wed Sep 09, 2009 9:38 pm Reply with quote

OH! Right you are! I missed that the first time around. Thank you! That worked!
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Modules

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©