I am trying to pull the email addresses from a mySQL table called "history". I need the loop statement to go through each record and pull the value of "e-mail" and "return date" for each record where the field checked_in='out'. Basically I am trying to compare todays date with the return date and echo out "laptop is late" for each record where its status is checked out. Eventually I need to get these values into a format that i can use the mail() function with. This is what i have right now. It just pulls the return date by itself. I also pulled the number of rows in the table for the loop statement? not really sure if that is the right way to do it. Any help is greatly appreciated. I have a tough time with loop statements. $yesterday = date('Y/m/d', mktime(0, 0, 0, date("m") , date("d") - 1, date("Y"))); $today = date('Y/m/d', mktime(0, 0, 0, date("m") , date("d") , date("Y"))); $tomorrow = date('Y/m/d', mktime(0, 0, 0, date("m") , date("d") + 1, date("Y"))); //echo date("Y-m-d", strtotime("-1 day") ) ."<br />"; //echo date("Y-m-d", strtotime("now") ) ."<br />"; //echo date("Y-m-d", strtotime("+1 day") ) ."<br />"; echo $today; $query = "SELECT rdate FROM history WHERE checked_in='out'"; $result = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array($result); $rdate = $row['rdate']; echo $rdate; $result = mysql_query("SELECT * FROM history"); $num_rows = mysql_num_rows($result); echo $num_rows; $i=1; while ($rdate < $today);{ echo "laptop is late"; } PHP:
2nd query, do this $query = "SELECT rdate FROM history WHERE checked_in='out'"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)) { if($row['rdate'] < $today) { echo $row['rdate'] . " laptop is late"; } } $rdate = $row['rdate']; Code (markup):
Thank you. That was exactly what i needed. I have it pull the email from the database and then send an email telling them that the laptop is overdue using the php mail() function. It is working great thank you again for your help and quick response. RESOLVED