note 75425 deleted from function.date by tularis
| From: | tularis@php.net | Date: | Wed, 30 May 2007 12:11:09 +0000 |
| Subject: | note 75425 deleted from function.date by tularis | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-127022@lists.php.net to get a copy of this message | ||
Note Submitter: sudhirdadwal at yahoo dot com
Reason: useless
----
//script to update a hit counter table field.I write this code
to count the total visiting on a page every the month. But you will need script to count total hits
on your web page. ////
<?php
$table_name1 = "sometable"; //table name in which you want to change
$wherecondition1 = "somefield = value"; // where condition
$field1 = "somefieldtoaccess"; //field to be access as result
$res = monthview($table_name1, $wherecondition1,$field1); //function call here
//update query
$q_insert = "UPDATE ".$table_name1." SET somefield = ".$res." WHERE
".$wherecondition1;
$exe_insert=mysql_query($q_insert) or die(mysql_error());
//////////
function to find a field value with a where condition on the dates matching
//////////
function monthview($table_name, $wherecondition,$field)
{
$mnth = date('t');
$mnnam = date('n');
$yr = date('Y');
$arr1 = array($mnth,$mnnam,$yr);
$last_date = implode("/",$arr1); //"31/5/2007"; last date
$day2 = date('j');
$mn2 = date('n');
$yr2 = date('Y');
$arr2 = array($day2,$mn2,$yr2);
$today_date = implode("/",$arr2); //"31/5/2007"; Today date
if($last_date==$today_date)
{
$q_select = "SELECT * FROM ".$table_name." WHERE
".$wherecondition;
$exe_select = mysql_query($q_select) or die(mysql_error());
$fetch_select = mysql_fetch_array($exe_select);
$result = $fetch_select[$field];
return $result;
}
}
?>