note 75425 added to function.date
| From: | sudhirdadwal at yahoo dot com | Date: | Tue, 29 May 2007 14:45:27 +0000 |
| Subject: | note 75425 added to function.date | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-126999@lists.php.net to get a copy of this message | ||
//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;
}
}
?>
----
Server IP: 203.199.124.111
Probable Submitter: 203.134.204.196
----
Manual Page -- http://www.php.net/manual/en/function.date.php
Edit -- https://master.php.net/note/edit/75425
Del: integrated -- https://master.php.net/note/delete/75425/integrated
Del: useless -- https://master.php.net/note/delete/75425/useless
Del: bad code -- https://master.php.net/note/delete/75425/bad+code
Del: spam -- https://master.php.net/note/delete/75425/spam
Del: non-english -- https://master.php.net/note/delete/75425/non-english
Del: in docs -- https://master.php.net/note/delete/75425/in+docs
Del: other reasons-- https://master.php.net/note/delete/75425
Reject -- https://master.php.net/note/reject/75425
Search -- https://master.php.net/manage/user-notes.php