this might explain it a bit better
$result2=mysql_query("select contact_id,mobile_no from mrbs_tel");
while ($getid = mysql_fetch_row($result2))
{
$result=mysql_query("select start_time, end_time, room_id, name, description from mrbs_entry where room_id = $getid[0] and start_time >= '$today_start' and end_time < '$today_end'");
while ($i = mysql_fetch_row($result))
{
if(mysql_num_rows($result) > 1)
{
$insert = "insert into mrbs_dupes values (\"\",\"$i[2]\",\"$i[0]\",\"$i[1]\",\"$i[3]\",\"$i[4]\")";
$inserted = mysql_query($insert);
$selectdupes = mysql_query("select * from mrbs_dupes where room_id = '$i[2]'");
$selecteddupes = mysql_fetch_row($selectdupes);
echo "DUPES - $selecteddupes[1]<br>";
}
else
{
//Get time of appointment
$start_time = date("H:i", $i[0]);
$end_time = date("H:i", $i[1]);
//Store mobile number of contact
$tel = str_replace(" ", "", $getid[1]);
$mobile = substr($tel, 1);
$mobile_tel = "44$mobile";
//Trim the text message body to 160 characters and replace spaces / multiple spaces with +
$trimbody = nicetrim($i[3]);
$checkbody = str_replace(" ", "+", str_replace("-", "", $trimbody));
$recheckbody = str_replace("++", "+", $checkbody);
$finalstripbody = str_replace("++", "+", $recheckbody);
$body = "Your+schedule+for+tomorrow+is:+$start_time+-+$end_time+$finalstripbody";
//Add all info into the url to be sent to fastsms
$url = "http://api.fastsms.co.uk/api/api.php?Username=un&Password=pass&Action=Send&DestinationAddress=$mobile_tel&SourceAddress=add&Body=$body";
//Send the URL to fastsms to be processed - comment out while testing
#include $url;
//List all contacts message was sent to (use only while in development)
echo "Message was sent to $mobile_tel - $i[2] with the text $body<br>$url<br><br>";
}
}
}
I can't do what you have suggested as the duplicate room entries change on each run of the script. I need to be able to pull this info out on the fly and merge the multiple sets of data in one statement i.e. one for room_id, one for name etc etc any advice?