Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

help mysql request


tangocharly

Recommended Posts

Posted

Hello,

 

I have start to devel a php script for osc to get unique hit from referer for a link listing in a category of my website.

To do this i have take the table and functions for banners.

I would want to insert entry in a table only if no data has been insert with the ip of the visitor and date < 24 hours.

 

Here my table :

links_history_ip_id      int(11)     	 Non        auto_increment      
links_id                  int(11)          Non      0
ip_hits                  varchar(15)    Non    0
links_history_ip_date 	 datetime      Non 	 0000-00-00 00:00:00

 

here the scripting i hope you could help me

  function tep_check_unique_hit($link_id) {
$count_hit = false;
$ip_address = tep_get_ip_address();

   $ip_count_query = tep_db_query("select count(*) as total from " . TABLE_LINKS_HISTORY_IP . " where ip_hits = '" . $ip_address . "' and links_id = '" . (int)$link_id . "'"); !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
   $ip_count = tep_db_fetch_array($ip_count_query);

if ($ip_count['total'] == 0) {
 INSERT in table 
  $count_hit = true;
}
return $count_hit;
 }

 

i know that where i have put the !!!!!!!!!!!!!!!! i have to put something like that :

and date_format(now(), '%Y%m%d %H:%i:%s') > date_format(links_history_ip_date, '%Y%m%d %H:%i:%s')+24 hours

 

i just need somebody to give me this end of code (and date ...) in the good syntax .

 

Thanks to help me

Tangocharly

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...