$text="text.";
//fetch from DB
$sql=mysql_query("SELECT * FROM `employee`");
while($query=mysql_fetch_array($sql))
{
echo $employee_mobile=$query['employee_mobile'];
echo $url="http://mobile.ssexpertcompu.com/vendorsms/pushsms.aspx?user=MYUSERNAME&password=MYPASSWORD&msisdn=".$employee_salary."&sid=78NSL&msg=".$text."&fl=0&gwid=2";
$url = str_replace(" ","%20",$url); // to properly format the url
$ch = curl_init();
$timeout = 5;
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
echo $data = curl_exec($ch);
curl_close($ch);
}
First employee record are fetched from DB,then using curl I'm sending message to their respective mobile numbers.The code for sending messages works fine without loop. I've seen some post how to use curl in a loop, but couldn't modify to my needs.