Hi Experts,

I have a table and I want to check once in a day if some records have been added or removed from this table within last 24hours ,and then send an e-mail to myself of all those added or removed records only .

Any idea about how can this be done?

many Thanks in advance.

Firstly you need to log some table data to compare in future.
Lets say primary key of table.
Create one table table_log which will have all primary key.

tbl_log:
id primary_key datetime
1 12,13,14,16,19,20,21 timestamp
2 12,13,14,19,20,21,22,23 timestamp

Now make one php script which will be set in cron job.
Task of php script is as below:
It takes last entry from table_log and export primary_key by ','
Then make a loop to compare with existing table primary_key.
Based on that you can check whether record is deleted or added and you can make an email for that.
Lastly take all primary key from you table and implode it and insert into table table_log for next compare.

Hi

Thanks a lot for the reply, but m a little new to php/sql. so would you mind telling me please , how can we set a loop to check two tables against each other using a primary key id ? as you stated in your solution?

Thanks

Okay dude..
This is with form code.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?
	mysql_connect('localhost','root','');
	mysql_select_db('test');	
	
	mysql_query('SET character_set_results=utf8');
	mysql_query('SET names=utf8');
	mysql_query('SET character_set_client=utf8');
	mysql_query('SET character_set_connection=utf8');
	mysql_query('SET character_set_results=utf8');
	mysql_query('SET collation_connection=utf8_general_ci');
	
	if(isset($_POST['save']))
	{
		$sql = "insert into tbl_hindi values ('".$_POST['data']."')";
		mysql_query($sql);
	}
	
	$sql = "select * from tbl_hindi";
	$res = mysql_query($sql);		
		
?>
<form  method="post">
<table width="900%" border="0">
  <tr>
    <td>Add New : <input type="text" name="data" size="20" />
<input type="submit" name="save" value="Save" /></td>
  </tr>
  <tr>
    <td>-----------------------------</td>
  </tr>
  <tr>
    <td><strong>Hindi Data</strong></td>
  </tr>
  <? while($sar = mysql_fetch_assoc($res)) { ?>
  <tr>
    <td><?=$sar['data'];?></td>
  </tr>
  <? } ?>
</table>
</form>
</body>
</html>
commented: fabulous , awsome , thanks +3

Hey
Thanks a lot for writing this much long code just for me. I think that you have also solved my problem in past as well. My this problem is also solved.
thanks a lot, i wish i could send you a cup of coffee on daniweb. :-)

[by mistake]

Hey
did you send a blank reply? I cant see the message.

Thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.