Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [HTML][PHP]Problem w ustawieniu stylu css dla $data[$row][]
sylwekb
post 18.10.2009, 18:40:17
Post #1





Grupa: Zarejestrowani
Postów: 124
Pomógł: 0
Dołączył: 12.01.2006

Ostrzeżenie: (0%)
-----


Witam, mam problem z poprawnym dodaniem stylu css dla $data[$row][] chciałem ustawić bacground czyli białe tło #FFFFFF o wielkości 150 px na 150px dla fragmentu $data[$row][] = '<a href="'.$product['product_flypage'].'" title="'.$product['product_name'].'">'
. ps_product::image_tag( $product['product_thumb_image'] )
. '</a>';
if( _SHOW_PRICES && $auth['show_prices'] ) {.
Jak można coś takiego wstawić do tego kodu php aby nie generowało błędów składni? Cały kod poniżej

  1. <?php if( !defined( '_VALID_MOS' ) && !defined( '_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' );
  2. mm_showMyFileName(__FILE__); ?>
  3.  
  4. <?php echo $buttons_header // The PDF, Email and Print buttons ?>
  5. <?php echo $browsepage_header // The heading, the category description ?>
  6. <?php echo $parameter_form // The Parameter search form ?>
  7. <?php echo $orderby_form // The sort-by, order-by form PLUS top page navigation ?>
  8.  
  9. <?php
  10. $data =array(); // Holds the rows of products
  11. $i = 1; $row = 0; // Counters
  12.  
  13. // Creates a new HTML_Table object that will help us
  14. // to build a table holding all the products
  15. $table =& new HTML_Table('width="100%"');
  16.  
  17. foreach( $products as $product ) {
  18.  
  19. foreach( $product as $attr => $val ) {
  20. // Using this we make all the variables available in the template
  21. // translated example: $this->set( 'product_name', $product_name );
  22. $this->set( $attr, $val );
  23. }
  24. $data[$row][] = '<a href="'.$product['product_flypage'].'" title="'.$product['product_name'].'">'
  25. . ps_product::image_tag( $product['product_thumb_image'] )
  26. . '</a>';
  27. if( _SHOW_PRICES && $auth['show_prices'] ) {
  28. $data[$row][] = '<a href="'.$product['product_flypage'].'" title="'.$product['product_name'].'">'.$product['product_name'].'</a>';
  29. $data[$row][] = $product['product_price'];
  30. }
  31. if( $product['has_addtocart'] ) {
  32. $data[$row][] = $product['form_addtocart'];
  33. }
  34. else {
  35. $data[$row][] = '<a href="'.$product['product_flypage'].'" title="'.$product['product_name'].'">'
  36. . $product['product_details']
  37. . '</a>';
  38. }
  39.  
  40. $row++;
  41.  
  42. }
  43.  
  44.  
  45. // Loop through each row and build the table
  46. foreach($data as $key => $value) {
  47.  
  48. $table->addRow( $data[$key], 'class="sectiontableentry'.$i.'"', 'td', true );
  49. $i = $i == 1 ? 2 : 1;
  50. }
  51. // Display the table
  52. echo $table->toHtml();
  53. ?>
  54. <br class="clr" /><br />
  55. <?php echo $browsepage_footer ?>
  56. <?php
  57. // Show Featured Products
  58. if( $this->get_cfg( 'showFeatured', 1 )) {
  59. /* featuredproducts(random, no_of_products,category_based) no_of_products 0 = all else numeric amount
  60. edit featuredproduct.tpl.php to edit layout */
  61. echo $ps_product->featuredProducts(true,10,true);
  62. } ?>
  63. <?php echo $recent_products ?>


Ten post edytował sylwekb 19.10.2009, 08:49:25
Powód edycji: [nospor]:
Go to the top of the page
+Quote Post
Blame
post 18.10.2009, 19:08:25
Post #2





Grupa: Zarejestrowani
Postów: 678
Pomógł: 124
Dołączył: 26.09.2009

Ostrzeżenie: (0%)
-----


Spróbuj tak:
  1. echo '<div id="przyklad">';
  2.  
  3. $data[$row][] = '<a href="'.$product['product_flypage'].'" title="'.$product['product_name'].'">'
  4. . ps_product::image_tag( $product['product_thumb_image'] )
  5. . '</a>';
  6. echo '</div>';


I w CSS'ie:

  1. #przyklad{
  2.  
  3. background-color:#FFF;
  4.  
  5. width: 150px;
  6.  
  7. height: 150px;
  8. }


Nie jestem pewny czy zadziała, w php jestem raczej początkujący, ale chcę pomóc i podeję sposób w jaki ja bym to zrobił.

Ten post edytował Blame 18.10.2009, 19:46:40


--------------------
Go to the top of the page
+Quote Post
sylwekb
post 18.10.2009, 19:18:50
Post #3





Grupa: Zarejestrowani
Postów: 124
Pomógł: 0
Dołączył: 12.01.2006

Ostrzeżenie: (0%)
-----


Właśnie w ten sposób próbowałem to robić ale generuje błąd

Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';'

Ten post edytował sylwekb 18.10.2009, 19:20:07
Go to the top of the page
+Quote Post
Blame
post 18.10.2009, 19:47:34
Post #4





Grupa: Zarejestrowani
Postów: 678
Pomógł: 124
Dołączył: 26.09.2009

Ostrzeżenie: (0%)
-----


Przepraszam cię ale tu wychodzi moje niedbalstwo. Musisz poprawić obydwa echo, tak jak w moim poprzednim poście i powinno działać.

Ten post edytował Blame 18.10.2009, 19:48:06


--------------------
Go to the top of the page
+Quote Post
sylwekb
post 19.10.2009, 08:37:17
Post #5





Grupa: Zarejestrowani
Postów: 124
Pomógł: 0
Dołączył: 12.01.2006

Ostrzeżenie: (0%)
-----


Już wszystko super wygląda. Dodałem punkt do reputacji za rozwiązanie problemu z błędem składni php.

  1. $data[$row][] = '<div id="przyklad"><a href="'.$product['product_flypage'].'" title="'.$product['product_name'].'">'
  2. . ps_product::image_tag( $product['product_thumb_image'] )
  3. . '</a></div>';


Ten post edytował sylwekb 19.10.2009, 08:47:35
Go to the top of the page
+Quote Post
nospor
post 19.10.2009, 08:40:58
Post #6





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




po pierwsze: uzywaj wlasciwego bbcode. Dla kodu php ma to byc bbcode PHP

po drugie: twoj kod wyglada po stworzeniu w skrocie tak:
  1. <a>
  2. <div id="przyklad">jakastresc
  3. </a>
  4. </div>';
Naprawde nie widzisz tu nic złego?


--------------------

"Myśl, myśl, myśl..." - Kubuś Puchatek || "Manual, manual, manual..." - Kubuś Programista
"Szukaj, szukaj, szukaj..." - Kubuś Odkrywca || "Debuguj, debuguj, debuguj..." - Kubuś Developer

Go to the top of the page
+Quote Post
sylwekb
post 19.10.2009, 08:50:39
Post #7





Grupa: Zarejestrowani
Postów: 124
Pomógł: 0
Dołączył: 12.01.2006

Ostrzeżenie: (0%)
-----


Wielkie dzięki, poprawiam swoje niedbalstwo. Już wszystko wygląda tak jak chciałem.
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 14.08.2025 - 09:57