<?php 
include("../db_connection.php");

if($_POST['value']=="approve")
{
	
	$sql=mysql_query("update tbl_ads set admin_status='Approved' where ads_id='".$_POST['id']."'");
	
	$sqlallu=mysql_query("select * from tbl_users");
	while($resallu=mysql_fetch_assoc($sqlallu))
	{
		mysql_query("insert into tbl_notification(user_id,ads_id,datetime) values('".$resallu['userid']."','".$_POST['id']."',now())");
	}
	
}
else
{
	$sql=mysql_query("update tbl_ads set admin_status='' where ads_id='".$_POST['id']."'");
	
	$sqlallu=mysql_query("select * from tbl_users");
	while($resallu=mysql_fetch_assoc($sqlallu))
	{
		mysql_query("delete from tbl_notification where user_id=''".$resallu['userid']."'' and ads_id='".$_POST['id']."'");
	}
}
?>