timmah1 Posted January 30, 2008 Share Posted January 30, 2008 I'm doing an auction site, and I need to select all items from a certain category that is equal to or greater than today's date, I don't want to show auctions that ended yesterday. Here is what i have $today = date("M j, Y"); $query2 = "SELECT * FROM items WHERE category = '$row1[name]' AND duration >= '$today'"; It don't display any items, yet there are 2 items listed under that category with a duration date of Feb 1, 2008. How can I fix this? Thanks in advance. Link to comment https://forums.phpfreaks.com/topic/88496-display-by-date/ Share on other sites More sharing options...
trq Posted January 30, 2008 Share Posted January 30, 2008 What field type is duration? Link to comment https://forums.phpfreaks.com/topic/88496-display-by-date/#findComment-453032 Share on other sites More sharing options...
timmah1 Posted January 30, 2008 Author Share Posted January 30, 2008 It's varchar, should it be date? Link to comment https://forums.phpfreaks.com/topic/88496-display-by-date/#findComment-453039 Share on other sites More sharing options...
timmah1 Posted January 30, 2008 Author Share Posted January 30, 2008 I changed it to date, and it works now. Thanks, AGAIN, thorpe Link to comment https://forums.phpfreaks.com/topic/88496-display-by-date/#findComment-453042 Share on other sites More sharing options...
timmah1 Posted January 30, 2008 Author Share Posted January 30, 2008 ok, got that to work. Here is my next problem. I have this $formatted_date3 = date("M j, Y H:i:s", strtotime("+3 Days")); $formatted_date5 = date("M j, Y H:i:s", strtotime("+5 Days")); $formatted_date7 = date("M j, Y H:i:s", strtotime("+7 Days")); $formatted_date10 = date("M j, Y H:i:s", strtotime("+10 Days")); $formatted_date15 = date("M j, Y H:i:s", strtotime("+15 Days")); But when I try to insert that into the database, it only inserts the date, not the time. The field type is datetime in the database DEFAULT is 0000-00-00 00:00:00 Can you help me with this one? Link to comment https://forums.phpfreaks.com/topic/88496-display-by-date/#findComment-453059 Share on other sites More sharing options...
timmah1 Posted January 30, 2008 Author Share Posted January 30, 2008 Maybe I wasn't real clear on this I have this code $formatted_date3 = date("M j, Y H:i:s", strtotime("+3 Days")); $formatted_date5 = date("M j, Y H:i:s", strtotime("+5 Days")); $formatted_date7 = date("M j, Y H:i:s", strtotime("+7 Days")); $formatted_date10 = date("M j, Y H:i:s", strtotime("+10 Days")); $formatted_date15 = date("M j, Y H:i:s", strtotime("+15 Days")); It produces this: <select name="duration" id="duration"> <option value="<?php echo "$formatted_date3" ?>">3 Days - <?php echo "$formatted_date3" ?></option> <option value="<?php echo "$formatted_date5" ?>">5 Days - <?php echo "$formatted_date5" ?></option> <option value="<?php echo "$formatted_date7" ?>">7 Days - <?php echo "$formatted_date7" ?></option> <option value="<?php echo "$formatted_date10" ?>">10 Days - <?php echo "$formatted_date10" ?></option> <option value="<?php echo "$formatted_date15" ?>">15 Days - <?php echo "$formatted_date15" ?></option> </select> But when trying to insert into the database, it only inserts the Date, not the time. Any reason why? Link to comment https://forums.phpfreaks.com/topic/88496-display-by-date/#findComment-453089 Share on other sites More sharing options...
timmah1 Posted January 30, 2008 Author Share Posted January 30, 2008 Anybody have anything about this? I know it's something simple, but I'm getting tired of bashing my head on the table Link to comment https://forums.phpfreaks.com/topic/88496-display-by-date/#findComment-453180 Share on other sites More sharing options...
kenrbnsn Posted January 30, 2008 Share Posted January 30, 2008 Please post the code used to update the database. Ken Link to comment https://forums.phpfreaks.com/topic/88496-display-by-date/#findComment-453271 Share on other sites More sharing options...
timmah1 Posted January 30, 2008 Author Share Posted January 30, 2008 $insert = mysql_query("INSERT INTO items VALUES ('NULL','".$_POST['type']."', NOW(),'$user[username]','".$_POST['item']."','".$_POST['quantity']."','".$_POST['condition']."','".$_POST['location']."','".$_POST['category']."','".$_POST['desc']."', '".$_POST['price']."', '$file_list', '".$_POST['shipping']."','".$_POST['shipping_details']."','".$_POST['duration']."','$1.00','".$_POST['custon']."','0','0')") or die("Sorry, there was a problem with uploading ".mysql_error()); Link to comment https://forums.phpfreaks.com/topic/88496-display-by-date/#findComment-453972 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.