Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Display latest product on main index?


maritc

Recommended Posts

Hi, I searched and searched without finding anything, so here I go...

 

Is there a way to link the newest added product in my store to my main index? I run a Norwegian scrapbooking website, that has both a store, forum and a layout gallery. I have a code that links the newest added picture in the gallery to my main index, and I would like to link the newest product to my main index, too. Does anybody have a code for this? I'd be very greateful if you could share it with me. Also, if anyone could tell me what the product table is called, I could try and edit the code I have for the gallery to apply to my store.

 

Thanks!

 

~Marit

Link to comment
Share on other sites

includes/modules/new_products.php has the code that you need. The products are in a table named products in most stores. Check the TABLE_PRODUCTS define in includes/database_tables.php

 

Hth,

Matt

Always back up before making changes.

Link to comment
Share on other sites

Thanks, Matt!

 

I tried to copy the code I have for my gallery and edit it to fit the store, but I couldn't quite get it. Could you please take a look at it and tell me what I'm doing wrong? TIA!

 

<?
$dbhost = 'xxx'; //this is you mysql server usually localhost
$dbname = 'xxx'; //Database name
$dbuser = 'xxx'; //Username
$dbpasswd = 'xxx'; //Password

$dbcon = mysql_connect($dbhost,$dbuser,$dbpasswd);
mysql_select_db($dbname);

?>
<table width="30%" cellpadding="3" cellspacing="1" border="0" class="forumline">
 <tr>
   <td class="catHead" height="28" colspan="2"><span class="cattitle">Nyeste produkt i butikken</span></td>
 </tr>
<?php
 $sql="SELECT c.*, p.*
   FROM products AS c
     LEFT JOIN products AS p ON c.categories_id = p.prodcts_id
   WHERE categories_id <> 0
   ORDER BY products_id DESC
   LIMIT 0,1";
 $result = mysql_query($sql) or die;
 while ($row = mysql_fetch_array($result))
 {
    print "<TR><TD align='center' class='row1'><a href='/catalog/product_info.php?products_id=" . $row['products_id'] . "'><img src='/catalog/popup_image.php?pID=" . $row['products_image'] . "'></a></TD></TR>";
   print "<TR><TD align='left' class='row2'><span class='gensmall'><b>Produkt : </b>" . $row['products_name'] . "<BR><b>Lagt ut : </b>" . $row['products_date_added'] . "<BR></P></span></a></TD></TR>";
 }
?>

 

I get a blank page with only the heading showing "Nyeste produkt i butikken" (Newest item added). I'm pretty new at php, so I got some help with the original album code. I was really hoping that I could just edit the code and add the proper database fields, and voila...but I guess it just wasn't that simple. :rolleyes:

 

Thanks again!

 

~Marit

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...