Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [HTML][PHP]pętla while
Forum PHP.pl > Forum > Przedszkole
sigal2006
Witam nie wiem jak przerobić pętle while tak aby co 3 wykonywany cykl dodawała mi fragment kody a dokładnie
  1. </tr><tr>
pętla wywala mi zaznaczone tabelki w poziomie chce aby był to blok czy ktoś mi pomoże myślałem że zastosuje funkcje
  1. <?if?>
ale coś mi nie wyszło



  1. while ($item_details = $db->fetch_array($sql_select_auctions))
  2. {
  3. $width = 100/$nb_auctions . '%';
  4.  
  5. $main_image = $db->get_sql_field("SELECT media_url FROM " . DB_PREFIX . "auction_media WHERE
  6. auction_id='" . $item_details['auction_id'] . "' AND media_type=1 AND upload_in_progress=0 ORDER BY media_id ASC LIMIT 0,1", 'media_url');
  7.  
  8. $auction_link = process_link('auction_details', array('name' => $item_details['name'], 'auction_id' => $item_details['auction_id']));
  9. $auction_link1 = ($item_details['auction_id']);
  10. $auction_link_max = process_link('auction_max', array('name' => $item_details['name'], 'auction_id' => $item_details['auction_id']));
  11. $start = ('');
  12. $koniec = ('');
  13. (string) $pm_methods = null;
  14. if (!empty($item_details['direct_payment']))
  15. {
  16. $dp_methods = $item->select_direct_payment($item_details['direct_payment'], $user_details['user_id'], true, true);
  17.  
  18. $pm_methods = $db->implode_array($dp_methods, ', ') . '<br>';
  19. }
  20.  
  21. if (!empty($item_details['payment_methods']))
  22. {
  23. $offline_payments = $item->select_offline_payment($item_details['payment_methods'], true, true);
  24.  
  25. $pm_methods .= $db->implode_array($offline_payments, ', ');
  26. }
  27.  
  28. $compared_items_content .= '' . $start . '<td width="' . $width . '" align="center" valign="top" class="catfeatmaincell"> '.
  29. '<table width="100%" border="0" cellspacing="2" cellpadding="5" class="catfeattable"><tr><td><table width="100%" class="border"> '.
  30. ' <tr class="c2"> '.
  31. ' <td class="smallfont" height="50"><center><b><a href="' . $auction_link . '">' . $item_details['name'] . '</a></b></center></td> '.
  32. ' </tr></table>'.
  33. ' <tr class="smallfont" height="200"> '.
  34. ' <td align="center" class="catfeatpic"><a href="' . $auction_link . '"><img src="' . (((!empty($main_image)) ? 'thumbnail.php?pic=' . $main_image . '&w=200&sq=Y' : 'themes/' . $setts['default_theme'] . '/img/system/noimg.gif')) . '" border="0" alt="' . $item_details['name'] . '"></a></td> '.
  35. ' </tr> '.
  36. ' <tr><td align="right"><b>Nr. aukcji </b> ' . $auction_link1 . ' ' . user_pics1($item_details['owner_id']) . ' <table width="100%" class="border"><tr> '.
  37. ' <td height="50">' . $item_details['username'] . ' ' . user_pics($item_details['owner_id']) . '</td> '.
  38. ' </tr></table><br /> '.
  39. ' <table width="100%" class="border"><tr> '.
  40. ' <td class="catfeatc1"></td> '.
  41. ' </tr> '.
  42. ' <tr> '.
  43. ' <td class="catfeatc1"><b>' . GMSG_START_TIME . ':</b> ' . show_date($item_details['start_time']) . ' <br> '.
  44. ' <b>' . GMSG_END_TIME . ':</b> ' . show_date($item_details['end_time']) . ' </td> '.
  45. ' </tr> '.
  46. ' <tr> '.
  47. ' <td class="catfeatc1"><b>' . MSG_START_BID . ':</b> ' . $fees->display_amount($item_details['start_price'], $item_details['currency']) . ' <br> '.
  48. ' <b>' . MSG_CURRENT_BID . ':</b> ' . $fees->display_amount($item_details['max_bid'], $item_details['currency']) . ' <br> '.
  49. ' <b>' . MSG_NR_BIDS . ':</b> ' . $item_details['nb_bids'] . '</td> '.
  50. ' </tr> '.
  51. ' <tr> '.
  52. ' <td class="catfeatc1"><b>' . GMSG_BUYOUT . ':</b> ' . (($item_details['buyout_price']<=0) ? GMSG_NO : GMSG_YES . ', <b>' . GMSG_PRICE . ': ' . $fees->display_amount($item_details['buyout_price'], $item_details['currency']) . '</b>') . ' </td> '.
  53. ' </tr> '.
  54. ' <tr> '.
  55. ' <td class="catfeatc1"><b>' . MSG_PAYMENT_METHODS . ':</b> <br>' . $pm_methods . ' </td> '.
  56. ' </tr></table><br /> '.
  57. ' <table width="100%" class="border"><tr> '.
  58. ' <td class="catfeatc1" align="right">Odznacz aby nie porównywać w kolejnym rozdaniu <input type="checkbox" name="auction_id[]" value="' . $item_details['auction_id'] . '" checked></td></tr></table></td> '.
  59. ' </tr> '.
  60. '</table></td>
  61. #
  62.  
  63.  
  64. ' . $koniec . ' ';
  65. }
lDoran
  1. while(......) {
  2. if($i % 3 == 0)
  3. echo '</tr><tr>';
  4. $i++
  5. }
sigal2006
nie zabardzo rozumiem jak mam to wykorzystać nową pętle mam zrobić czy już istniejącą przerobić ? a te ........ ?
lDoran
1. Przed swoją pętlą dajesz $i=0;
2. w pętli dajesz if'a
3. w pętli na samym końcu inkrementujesz $i
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.