mikebyrne Posted January 23, 2008 Share Posted January 23, 2008 I want my program to list all orders that have been procesed today. At present my code looks like <table width="850" border="0" cellspacing="0" cellpadding="0"> <?php // let's get some data include('adminconnect.php'); $sql = mysql_query("SELECT OrderNo, Orderdate, Custname, Amount, Shippingmet FROM admin WHERE Orderdate = 01/22/08"); while( $row = mysql_fetch_array($sql) ) { // loop through and display ?> <tr align="left"> <td width="33"> </td> <td width="82"><a href="javascript:openWindow('popup_detail.html', 'NewWindow', 615, 600)" class="black"><?php echo $row['OrderNo'];?></a></td> <td width="61"><?php echo $row['Orderdate'];?></td> <td width="61"><?php echo $row['Dispatchdate'];?></td> <td width="230"><?php echo $row['Custname'];?></td> <td width="170"><?php echo $row['Trackno'];?></td> <td width="56" align="right"><?php echo $row['Amount'];?></td> <td width="21"> </td> <td width="136">test</td> </tr> <? } ?> </table> Is the a varible that will automatically assign todays date so I wont have to keep changing the date?? Also the date fields are in US Format in my database so that will make a difference Link to comment https://forums.phpfreaks.com/topic/87367-solved-sort-by-date-problem/ Share on other sites More sharing options...
rajivgonsalves Posted January 23, 2008 Share Posted January 23, 2008 this $sql = mysql_query("SELECT OrderNo, Orderdate, Custname, Amount, Shippingmet FROM admin WHERE Orderdate = 01/22/08"); should be $sql = mysql_query("SELECT OrderNo, Orderdate, Custname, Amount, Shippingmet FROM admin WHERE Orderdate = CURR_DATE"); hope its helpful Link to comment https://forums.phpfreaks.com/topic/87367-solved-sort-by-date-problem/#findComment-446894 Share on other sites More sharing options...
mikebyrne Posted January 23, 2008 Author Share Posted January 23, 2008 I tried that before but I'm getting an error Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\xampp\htdocs\Admin_files\New.php on line 210 Line 210 refers to //loop through records so i assume the line above it is the problem Link to comment https://forums.phpfreaks.com/topic/87367-solved-sort-by-date-problem/#findComment-446898 Share on other sites More sharing options...
rajivgonsalves Posted January 23, 2008 Share Posted January 23, 2008 try this $sql = mysql_query("SELECT OrderNo, Orderdate, Custname, Amount, Shippingmet FROM admin WHERE Orderdate = DATE_FORMAT(now(),'%m/%d/%y')") or die("Cannot execute :".mysql_error()); Link to comment https://forums.phpfreaks.com/topic/87367-solved-sort-by-date-problem/#findComment-446900 Share on other sites More sharing options...
mikebyrne Posted January 23, 2008 Author Share Posted January 23, 2008 THANKS!!!! Link to comment https://forums.phpfreaks.com/topic/87367-solved-sort-by-date-problem/#findComment-446912 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.