Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Need help with SQL


JenOcide

Recommended Posts

On the home page, there is the mod that displays any Upcoming Products and the Date Expected.

 

The date expected is taken from the date you provided in the Date Available field when adding the new product within the admin area.

 

I would like to make use of this date within my product_info pages. I plan on adding a heading 'Release Date', which will look at the date provided in the Date Available field for that product, and then display it.

 

Although still learning, I've attempted the SQL to the point where there are no more errors created by it. The problem I've got now is that the date displayed for all my products is 30/11/2036, regardless of when the Date Expected is. If no date is provided it still displays 30/11/2036.

 

I've looked at the code that much, I feel I'm over-looking the most simplest of problems! I'd appreciate another set of eyes to give it the once over, not in the sense that I'd like another set of eyes, just for someone else to look at the code (see, this problem is sending me loopy!).

 

Anyway, what I've done so far is as follows:

 

<?php

$expected_query = tep_db_query("select products_date_available from " . TABLE_PRODUCTS . " where products_id =  '" . $product_info['products_id'] . "'");

if ($expected_query == '') {
 echo '<span class="releasedate">TBA</span>';
 } else {
 echo '<span class="releasedate">' . tep_date_short($expected_query['products_date_available'] . '</span>');
}

?>

 

FYI, being from the UK the date format set in my english.php is:

 

define('DATE_FORMAT', 'd/m/Y');

 

When this is reverted back to the American format, it displays 11/30/2036.

 

I think that's about as much info I can give you.

 

Thank you in advance :)

Link to comment
Share on other sites

I think I've got it sorted out now :D

 

After looking around the existing code some more, I ended up using the following:

 

<?php

if ($product_info['products_date_available'] == '') {
 echo '<span class="releasedate">TBA</span>';
 } else {
 echo sprintf(tep_date_long($product_info['products_date_available']));
 }
?>

 

So far it seems to work, but I need to test it some more to be certain.

Link to comment
Share on other sites

Sorry for adding another reply, but you can't edit your posts!

 

The above seems to be working just fine now, but I'm not happy with the date format.

 

1. When using short date, I get for example 31/12/2003

 

2. When using long date, I get Wednesday 31 December, 2003

 

The problem with short date is that there may be confusion if it displays 01/03/2004. Europeans will take this as 1st March, 2004, whereas Americans will take it as January 3rd, 2004.

 

Therefore I'd like to go with option 2, only I don't like the way it is presented.

 

I want to replace:

 

Wednesday 31 December, 2003

 

with:

 

31st December, 2003

 

Does anyone know how to go about defining the date in this format with the desired prefixes?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...