Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

BBC News style scrolling text


dragondust

Recommended Posts

Hi All

 

I'm just playing with a feature I've found on the web which enables a BBC news type scrolling text.

 

See it in action dragondust beta site

 

I'm having some problems with it at the mo though.

 

here some code I've borrowed from the new_products.php file to get it self populating.

 

  
 $row = 0;
 $col = 0;
[color="#FFFF00"]//  $info_box_contents = array()  ;[/color]
 while ($new_products = tep_db_fetch_array($new_products_query)) {
   $scrollingtext[$row][$col] = array('text' => '<li><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id']) . '">' . $new_products['index_fp_title'] . ': Just ' . ($currencies->display_price($new_products['products_price'], tep_get_tax_rate($new_products['products_tax_class_id']))) . '</a></li>');

   $col ++;
[color="#FFFF00"]//    if ($col > 2) {
//     $col = 0;
//      $row ++;
//   }[/color]
 }

 new contentBox($info_box_contents);

 

 

 

The problem I seem to have is the removal of the tables in this file.

 

At the moment the code reads

 

<ul id="news">
<table border="0" width="100%" cellspacing="0" cellpadding="1" class="infoBox">
 <tr>
   <td><table border="0" width="100%" cellspacing="0" cellpadding="4" class="infoBoxContents">
 <tr>
   <td><li><a href="http://www.rjavtest.com/lethal-weapon.html">Action Comedy: Lethal Weapon: Just £34.99</a></li></td>
   <td><li><a href="http://www.rjavtest.com/courage-under-fire.html">Drama: Courage Under Fire: Just £29.99</a></li></td>
   <td><li><a href="http://www.rjavtest.com/frantic.html">Thriller: Frantic: Just £35.00</a></li></td>
   <td><li><a href="http://www.rjavtest.com/fire-down-below.html">Action: Fire Down Below: Just £29.99</a></li></td>
   <td><li><a href="http://www.rjavtest.com/hewlett-packard-laserjet-1100xi.html">Printer: HP LaserJet 1100: Just £499.99</a></li></td>
   <td><li><a href="http://www.rjavtest.com/beloved.html">Beloved: Just £54.99</a></li></td>
   <td><li><a href="http://www.rjavtest.com/die-hard-with-a-vengeance.html">Action: Die Hard With A Vengeance: Just £39.99</a></li></td>
   <td><li><a href="http://www.rjavtest.com/blade-runner-director-s-cut.html">Science Fiction: Blade Runner: Just £30.00</a></li></td>
   <td><li><a href="http://www.rjavtest.com/a-bug-s-life.html">Animation: A Bug's Life: Just £35.99</a></li></td>
 </tr>
</table>
</td>
 </tr>
</table>
</ul>

 

Yet it would be better reading.

 

<ul id="news">
   <li><a href="http://www.rjavtest.com/lethal-weapon.html">Action Comedy: Lethal Weapon: Just £34.99</a></li>
   <li><a href="http://www.rjavtest.com/courage-under-fire.html">Drama: Courage Under Fire: Just £29.99</a></li>
   <li><a href="http://www.rjavtest.com/frantic.html">Thriller: Frantic: Just £35.00</a></li>
   <li><a href="http://www.rjavtest.com/fire-down-below.html">Action: Fire Down Below: Just £29.99</a></li>
   <li><a href="http://www.rjavtest.com/hewlett-packard-laserjet-1100xi.html">Printer: HP LaserJet 1100: Just £499.99</a></li>
   <li><a href="http://www.rjavtest.com/beloved.html">Beloved: Just £54.99</a></li>
   <li><a href="http://www.rjavtest.com/die-hard-with-a-vengeance.html">Action: Die Hard With A Vengeance: Just £39.99</a></li>
   <li><a href="http://www.rjavtest.com/blade-runner-director-s-cut.html">Science Fiction: Blade Runner: Just £30.00</a></li>
   <li><a href="http://www.rjavtest.com/a-bug-s-life.html">Animation: A Bug's Life: Just £35.99</a></li>
</ul>

 

Has anybody got an ideal on how to remove the tables whilst keeping the new_products.php self populating.

 

Regards. Dragondust.

Link to comment
Share on other sites

Thank you for your quick reply.

 

Unfortunately I'm quite new to PHP and only have a very limited knowledge. I understand you regarding the first part of the coding but this is as far as I know. I can see it works as the tables are removed and it has populating the array on the webpage, but it also brings a fatal error see below.

 

This part I'm lost on and I'm guessing this is where it's failing.

 

then echo the $scrollingtext appropriately

 

I've tried a few combination and found that the closed I can get to this self populating is just the text in the coded line Just: $0.00.

 

I'll include all the code which the array is collecting the data from (the new_product.php) this file is located in the modules directory. Not that clear in the first message. I was half asleep.

 

 

[color="#FFFACD"]  if ( (!isset($index_fp_category_id)) || ($index_fp_category_id == '0') ) {
   $index_fp_query = tep_db_query("select p.products_id, ifp.index_fp_title, ifp.valid_from_date, ifp.status, ifp.index_fp_id,  if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id,  " . TABLE_INDEX_FP . " ifp, " . TABLE_PRODUCTS_DESCRIPTION . " pd where ifp.status = '1' and p.products_id = ifp.products_id and  p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' order by ifp.valid_from_date DESC limit " . MAX_RANDOM_SELECT_INDEX_FP);
 } else {
   $index_fp_query = tep_db_query("select distinct p.products_id, ifp.valid_from_date, ifp.index_fp_title, ifp.status, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id,  ifp.index_fp_id,  " . TABLE_INDEX_FP . " ifp, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c where p.products_status = '1' and p.products_id = ifp.products_id  and p.products_id = pd.products_id and pd.language_id = '" . (int)$new_products_category_id . "' and ifp.status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' order by ifp.valid_from_date DESC limit " . MAX_RANDOM_SELECT_INDEX_FP);
 }

$row = 0;
$col = 0;
 $scrollingtext = array()  ;
while ($index_fp = tep_db_fetch_array($index_fp_query)) {
   $scrollingtext[$row][$col] = array('text' => '<li><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $index_fp['products_id']) . '">' . $index_fp['index_fp_title'] . ': Just ' . ($currencies->display_price($index_fp['products_price'], tep_get_tax_rate($index_fp['products_tax_class_id']))) . '</a></li>');

   $col ++;
//    if ($col > 2) {
//     $col = 0;
//      $row ++;
//   }
 }

 new contentBox($scrollingtext);[/color]

 

The above is the old style which is still part of the same page below. I have also copied the fatal error message.

 

[color="#ADD8E6"]
//  $scrollingtext = array()  ;
// while ($index_fp = tep_db_fetch_array($index_fp_query)) {
//   $scrollingtext .= '<li><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $index_fp['products_id']) . '">' . $index_fp['index_fp_title'] . ': Just ' . ($currencies->display_price($index_fp['products_price'], tep_get_tax_rate($index_fp['products_tax_class_id']))) . '</a></li>' . "\n";

//  }

// seems to be the error point    new $scrollingtext();[/color]

[color="#FFFF00"]//Fatal error: Class 'Array<li><a href="http://www.rjavtest.com/lethal-weapon.html">Action Comedy: Lethal Weapon: Just £34.99</a></li> <li><a href="http://www.rjavtest.com/courage-under-fire.html">Drama: Courage Under Fire: Just £29.99</a></li> <li><a href="http://www.rjavtest.com/frantic.html">Thriller: Frantic: Just £35.00</a></li> <li><a href="http://www.rjavtest.com/fire-down-below.html">Action: Fire Down Below: Just £29.99</a></li> <li><a href="http://www.rjavtest.com/hewlett-packard-laserjet-1100xi.html">Printer: HP LaserJet 1100: Just £499.99</a></li> <li><a href="http://www.rjavtest.com/beloved.html">Beloved: Just £54.99</a></li> <li><a href="http://www.rjavtest.com/die-hard-with-a-vengeance.html">Action: Die Hard With A Vengeance: Just £39.99</a></li> <li><a href="http://www.rjavtest.com/blade-runner-director-s-cut.html">Science Fiction: Blade Runner: Just £30.00</a></li> <li><a href="http://www.rjavtest.com/a-bug-s-life.html">Animation in /home/catalog/includes/modules/tickets.php on line 55 [/color]

 

Has anyone any ideas.

 

Regards. Dragondust

Link to comment
Share on other sites

Hi Burt

 

Thank you for your help in enabling me to finish this.

 

$row = 0;
   while ($index_fp = tep_db_fetch_array($index_fp_query)) {
           echo  '<li><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $index_fp['products_id']) . '">' . $index_fp['index_fp_title'] . ': Just ' . ($currencies->display_price($index_fp['products_price'], tep_get_tax_rate($index_fp['products_tax_class_id']))) . '</a></li>' . "\n";;
   }

 

This is the final code. I'm just doing a couple of other modes on the site. So once I've finished. I shall make it available.

 

Regards. Dragondust.

Link to comment
Share on other sites

Join the conversation

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

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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...