Dear Friends,
I'm having a problem for a few days with an sql statement.
Idea: I'm trying to retrieve from table (sms_out) a list of mobile numbers. Each number with it's status of sent i.e Failed or Success.
The output should be like this:
Mobile No. ------------ Failed--------------Success--------------Total
0171112554 5 10 15
My effort until now was this:
This retrieve the mobile number. Then in Query1, it take the mobile number and get the number of FAILED. Query2 will get the number of SUCCESS.
$query="SELECT out_phone, count(status), count(*) AS total FROM muath_sms_out GROUP BY out_phone, status";
$row=mysql_fetch_array($result)
$hp=$row["out_phone"];
$query1="SELECT count(out_phone) as Failed FROM muath_sms_out where out_phone=$hp status='Failed'";
$result1=mysql_query($query1);
$row1=mysql_fetch_array($result1);
$query2="SELECT count(out_phone) as Success FROM muath_sms_out where out_phone=$hp status='Success'";
$result2=mysql_query($query2);
$row2=mysql_fetch_array($result2);
I got a warning for this:
$row1=mysql_fetch_array($result1);
And
$row2=mysql_fetch_array($result2);
Gentlemen, I seek your help as i'm very desperate into solving this problem.
MySQL client version: 5.0.51a
Thank you.
Best Regards,
Muath