Jump to content

display by date


timmah1

Recommended Posts

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
Share on other sites

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
Share on other sites

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
Share on other sites

$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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.