shams Posted May 13, 2006 Share Posted May 13, 2006 hi,i have mysql table treatment, each patient should come every month to collect his medicens exact in the same date of next month, at least for 8 months, i need a php script that show me the patients didn't collect their medicens after 30 days, these are called defaulters the output of the script will be like this:john is defaulter from 2006-3-11this is the incomplete php script for help please any one can complete this one: [code]<?php// Make a MySQL Connectionmysql_connect("localhost","root") or die(mysql_error());mysql_select_db("mydb") or die(mysql_error());$query = "SELECT name,fatherN,MAX(date) AS Lastdate FROM treatment GROUP BY name, fatherN HAVING TO_DAYS(NOW()) - TO_DAYS(Lastdate) > 30";$result = mysql_query($query) or die(mysql_error());while($row = mysql_fetch_array($result)) {echo $row['name']." ".$row['fatherN']." "."is defaulter from"." ".$row['Lastdate'];echo "<br />";} else { echo "No one is defaulter"; }?>[/code] Quote Link to comment Share on other sites More sharing options...
Barand Posted May 14, 2006 Share Posted May 14, 2006 You currently have an ELSE without an IFTry[code]<?php // do we have any rows returned? if ($row = mysql_fetch_array($result)) { do { echo $row['name']." ".$row['fatherN']." "."is defaulter from"." ".$row['Lastdate']; echo "<br />"; } while ($row = mysql_fetch_array($result)); } else { echo "No one is defaulter"; }?>[/code] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.