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. Quote Link to comment Share on other sites More sharing options...
trq Posted January 30, 2008 Share Posted January 30, 2008 What field type is duration? Quote Link to comment 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? Quote Link to comment 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 Quote Link to comment 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? Quote Link to comment 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? Quote Link to comment 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 Quote Link to comment 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 Quote Link to comment 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()); 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.