A little php question from Opencaching.us

All postings beginning with "How can i configure (or implement) ..."
Antworten
Mr.Yuck

Whether you agree or not, we at Opencaching.us want attended logs for events to increment your find count on the website. I've found the "increment user stats" code in log.php. If you ask me, it already should increment the find count. But any advice on why it doesn't? Can someone help us? log_type1 is found it, and log_type7 is attended.
//inc user stat
$rs = sql("SELECT `log_notes_count`, `founds_count`, `notfounds_count` FROM `user` WHERE `user_id`='&1'", $usr['userid']);
$record = sql_fetch_array($rs);

if ($log_type == 1 || $log_type == 7)
{
$tmpset_var = '`founds_count`=\'' . sql_escape($record['founds_count'] + 1) . '\'';
}
elseif ($log_type == 2)
{
$tmpset_var = '`notfounds_count`=\'' . sql_escape($record['notfounds_count'] + 1) . '\'';
}
elseif ($log_type == 3)
{
$tmpset_var = '`log_notes_count`=\'' . sql_escape($record['log_notes_count'] + 1) . '\'';
}
if ($log_type == 1 || $log_type == 2 || $log_type == 3 || $log_type == 7)
{
sql("UPDATE `user` SET " . $tmpset_var . " WHERE `user_id`='&1'", sql_escape($usr['userid']));
}
Benutzeravatar
bohrsty
Administrator
Administrator
Beiträge: 1361
Registriert: 30.03.2012, 22:54

of cause, this code increments the counter, the only thing i could imagine is that the "if-elseif" contruct doesn't match the $log_type correctly... is the $log_type set correctly to '7'?
gruss Nils (bohrsty)

Bild
Mr.Yuck

Thanks, I almost forgot I posted here! I will investigate that, but the more I look into this, I believe what I may have found here is the code that tabulates the number of found or attended logs on a cache page. Example picture below.

[img]http://farm6.staticflickr.com/5529/11800243333_4b6b618cf9.jpg[/img]
Mr.Yuck

OK then, maybe THIS is the right place on our website, in a file named found-caches.php. How would I add type 7 where it currently only has type 1?
$rs = sql('SELECT COUNT(`cache_logs`.`user_id`) `count`, `user`.`username` `username` FROM `cache_logs` INNER JOIN `user` ON (`user`.`user_id`=`cache_logs`.`user_id`) WHERE `cache_logs`.`deleted`=0 AND `cache_logs`.`type`=1 GROUP BY `cache_logs`.`user_id` ORDER BY `count` DESC LIMIT 25');
  while ($r = mysql_fetch_array($rs))
Benutzeravatar
flopp
Vereinsmitglied
Vereinsmitglied
Beiträge: 1008
Registriert: 18.03.2012, 17:02

I suggest:

Code: Alles auswählen

$rs = sql('SELECT COUNT(`cache_logs`.`user_id`) `count`, `user`.`username` `username` 
    FROM `cache_logs` 
    INNER JOIN `user` 
    ON (`user`.`user_id`=`cache_logs`.`user_id`) 
    WHERE `cache_logs`.`deleted`=0 AND (`cache_logs`.`type`=1 OR `cache_logs`.`type`=7) 
    GROUP BY `cache_logs`.`user_id` 
    ORDER BY `count` DESC LIMIT 25');
[url=http://www.flopp-caching.de/]Flopps Tolle Karte[/url] | [url=http://www.florian-pigorsch.de/oc]OC[/url] | [url=http://www.florian-pigorsch.de/gc]GC[/url] | [url=http://florian-pigorsch.de/+]G+[/url] | [url=http://florian-pigorsch.de/t]Tw[/url] | [url=http://florian-pigorsch.de/fb]Fb[/url]
Mr.Yuck

[quote="flopp"]
I suggest:

Code: Alles auswählen

$rs = sql('SELECT COUNT(`cache_logs`.`user_id`) `count`, `user`.`username` `username` 
    FROM `cache_logs` 
    INNER JOIN `user` 
    ON (`user`.`user_id`=`cache_logs`.`user_id`) 
    WHERE `cache_logs`.`deleted`=0 AND (`cache_logs`.`type`=1 OR `cache_logs`.`type`=7) 
    GROUP BY `cache_logs`.`user_id` 
    ORDER BY `count` DESC LIMIT 25');
[/quote]

That worked Flopp, thanks!! I didn't respond, because I found that I had to find similar code in SEVERAL different places on our website. I'm very close to being done, I have events counting as finds just about everywhere on the website. There's one spot that's giving me problems, and it has a different syntax. How do you supposed I could get a type=7 in this code in addition to type=1, and get it to work?

Code: Alles auswählen

$a = "SELECT COUNT(*) count, username, stat_ban, user.user_id FROM caches, cache_logs, user ".
     "WHERE `cache_logs`.`deleted`=0 AND cache_logs.user_id=user.user_id AND cache_logs.type=1 AND cache_logs.cache_id = caches.cache_id ".$typ." ".
     "GROUP BY user.user_id ".
     "ORDER BY 1 DESC, user.username ASC";
Benutzeravatar
flopp
Vereinsmitglied
Vereinsmitglied
Beiträge: 1008
Registriert: 18.03.2012, 17:02

You probably have to replace

Code: Alles auswählen

cache_logs.type=1
by

Code: Alles auswählen

(cache_logs.type=1 OR cache_logs.type=7)
[url=http://www.flopp-caching.de/]Flopps Tolle Karte[/url] | [url=http://www.florian-pigorsch.de/oc]OC[/url] | [url=http://www.florian-pigorsch.de/gc]GC[/url] | [url=http://florian-pigorsch.de/+]G+[/url] | [url=http://florian-pigorsch.de/t]Tw[/url] | [url=http://florian-pigorsch.de/fb]Fb[/url]
Mr.Yuck

[quote="flopp"]
You probably have to replace

Code: Alles auswählen

cache_logs.type=1
by

Code: Alles auswählen

(cache_logs.type=1 OR cache_logs.type=7)
[/quote]

Forgot to come back and thank you, Flopp. That worked perfectly!
Mr.Yuck

Oh, I'll just bump this thread, rather than start a new one. I see the last 5 or 6 threads are me asking for help anyways.  :P

OK, the language flags on the top of any of our sites. I joined opencaching.us the day of it's official release in 2010, but I didn't become an admin until 2013. I'm going to guess I didn't know what the flags were for for at least a year! And we only had Poland and the United States at the time anyways, I have since added Spain and France (not for Spain and France, but for Mexico, and the Canadian province of Quebec).

Opencaching.de has the word "Language:" in front of the flags. Could I do that? Here's a code snippet:

Code: Alles auswählen

 	<!-- HEADER -->
		<!-- OC-Logo -->
		<div><img src="./images/V2B68x64.jpg" alt="" style="margin-top:3px; margin-left:3px;" /></div>
    <!-- Sitename -->
		<div class="site-name">
      <p class="title"><a href="index.php">OPENCACHING</a></p>
      <p class="subtitle"><a href="index.php">Geocaching in North America</a></p>

    </div>
		
		<!-- Flag navigations -->
    <div class="navflag-container">
      <div class="navflag">
			  <ul>
          {language_flags}
        </ul>

		  </div>
    </div>			
Antworten