DONOR
donor-nic----username-----status
111----------ali----------available
222---------usman--------notavailable
another is
DONATION
donation_id------donor_nic-----date---
1----------------111----------2012/03/04
2---------------111-----------2012/06/07
3----------------111---------2012/07/08
4----------------222---------2012/03/03
now i want to update the date if it is already exits corresponding to donor_nic
if date does not exists i want to insert that new date,.
i am using this query to fetching all dates according to corresponding donor_nic
SELECT donor.donor_nic, donation.lastdonationdate
FROM donor
JOIN donation ON donor.donor_nic = donation.donor_nic
WHERE username = 'ali'
GROUP BY donation.lastdonationdate
now this query works in phpmyadmin.. but when i use this in my page.. it does not match date.. i am matching date like this
$sql= SELECT donor.donor_nic, donation.lastdonationdate
FROM donor
JOIN donation ON donor.donor_nic = donation.donor_nic
WHERE username = 'ali'
GROUP BY donation.lastdonationdate
$res=mysql_query($sql, $con);
if($res == $date)
{
echo "update";
}
else
{
echo "insert";
}
but this thing didnt work.. may be i am making mistake in conditional (if-else) statment.. plz help me what should i do..
thanks in advance
No comments:
Post a Comment