Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Urgent Help Needed - Site Due To Launch Tomorrow!!


Philster

Recommended Posts

Hi,

 

In a bit of a panic as I'm launching a site for my girlfriend tomorrow. Here's my dilema...

 

The following code ouputs a table with thumbnail images and links to my products in 3 columns:

 

  

$info_box_contents = array();

 $row = 0;

 $col = 0;

 while ($new_products = tep_db_fetch_array($new_products_query)) {

   $new_products['products_name'] = tep_get_products_name($new_products['products_id']);

   $info_box_contents[$row][$col] = array('align' => 'center',

                                          'params' => 'width="130"',

                                          'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id']) . '"><img src="/images/' . $new_products['products_image'] . '" alt="' . $new_products['products_name'] . ' - Click Here To View This Set" width="120" height="120" border="0" vspace="5"></a>');

   $col ++;

   if ($col > 2) {

     $col = 0;

     $row ++;

   }

 }

 new contentBox($info_box_contents);

 

At the minute, there are only 16 products, which means that there are 5 rows of 3 columsn, and one row with only 1 column, which looks a bit like this:

 

whatihave.gif

 

What I want, however, is that on the final row, if there is only one product, that that row has a colspan of 3, and the image is centered, as follows:

 

whatiwant.gif

 

Not only would it look neater, but it would also ensure that correct HTML was output (ie it's bad practise to have 1 row with 3 columns and the next with only 1).

 

Thing is, I'm fairly new to PHP and haven't a clue how to do this, so any help would be greatly appreciated!!

 

Damn last minute changes!! :shock:

 

Thanks in advance guys,

Phil

Link to comment
Share on other sites

Thanks but I don't think it's as simple as that. From what I can tell, it pulls a product from the database, displays the image and link, then creates a new column and does the same again until it has formed 3 columns per page. The problem arises when there are no products left, it doesn't create any further table cells, and in order to align things properly, it would need to merge the 3 last columns into 1 and align all contents to the center.

 

Like I said, I know what I want it to do, but I haven't a clue where to start!

 

Any other ideas?

 

Phil

Link to comment
Share on other sites

You could use a counter to determin the rows and column count prior to making the table.

 

Then, you can set the colspan to the size needed and center the image(s) inside that.

Link to comment
Share on other sites

You could use a counter to determin the rows and column count prior to making the table.

 

Then, you can set the colspan to the size needed and center the image(s) inside that.

 

Don't suppose you'd have a few minutes to take me through that Linda? I really wouldn't have a clue where to start...

 

It'd be much appreciated!! :)

 

Phil

Link to comment
Share on other sites

After I finish the project I am on ... I can. 8)

 

I'd like to add this feature myself and have it already half way there. I just need some time to finish it. :D

Link to comment
Share on other sites

Hi Linda,

 

Did you ever get this working? I resorted to hard coding the page in HTML (only 16 products for the coming months, so it was a perfectly viable option) but I'd love to know how to do it dynamically.

 

Phil

Link to comment
Share on other sites

Hi Linda,

 

Did you ever get this working? I resorted to hard coding the page in HTML (only 16 products for the coming months, so it was a perfectly viable option) but I'd love to know how to do it dynamically.

 

Phil

 

Not yet, still trying to get the SEC project out the door.

 

Then I will have more time to play ... :D

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...