Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php] więcej niż jeden if
olcia
post
Post #1





Grupa: Zarejestrowani
Postów: 62
Pomógł: 0
Dołączył: 28.06.2003
Skąd: TG

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


witajcie,
mam problem - potrzebuję tak zmienić skrypt, żeby najpierw sprawdział czy zmienna $c2 jest większa niż 0.00 jeżeli tak, to idziemy dalej i zaczyna się właściwy skrypt z if i else, potem else dla wartości zmiennej $cs2 i skrypt.
  1. <?php
  2. //najpierw if ($c2 = 0.00) { echo ""; } else { poniższy skrypt
  3.  
  4. if ($new_price = tep_get_products_special_price($product_info['products_id'])) {
  5. $c1 = $saveprice->display_price($new_price, tep_get_tax_rate($product_info['products_tax_class_id']));
  6. $c2 = $saveprice->display_price($product_info['products_price2'], tep_get_tax_rate($product_info['products_tax_class_id']));
  7. echo 'RRP ' . $products_price2 . '<br>our price ' . $products_price . '<br>';
  8. $save1 = ($c2 - $c1); 
  9. $save = (($c2 - $c1) / $c2 ) * 100;
  10. $save = round($save);
  11. echo "you save Ł$save1 or $save% of RRP";
  12.  
  13. } else {
  14.  
  15. $c1 = $saveprice->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id']));
  16. $c2 = $saveprice->display_price($product_info['products_price2'], tep_get_tax_rate($product_info['products_tax_class_id']));
  17. echo 'RRP ' . $products_price2 . '<br>our price ' . $products_price . '<br>';
  18. $save1 = ($c2 - $c1); 
  19. $save = (($c2 - $c1) / $c2 ) * 100;
  20. $save = round($save);
  21. echo "you save Ł$save1 or $save% of RRP";
  22. }
  23. ?>


z góry dziękuję za wskazówkę.
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
olcia
post
Post #2





Grupa: Zarejestrowani
Postów: 62
Pomógł: 0
Dołączył: 28.06.2003
Skąd: TG

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


najpierw jest
  1. <?php
  2. if ($c2 == 0.00) { 
  3. echo "nie ma nic";
  4. }
  5. else {
  6. //właściwy skrypt:
  7. if ($new_price = tep_get_products_special_price($product_info['products_id'])) {
  8. $c1 = $saveprice->display_price($new_price, tep_get_tax_rate($product_info['products_tax_class_id']));
  9. $c2 = $saveprice->display_price($product_info['products_price2'], tep_get_tax_rate($product_info['products_tax_class_id']));
  10. echo '<span class="rrp">RRP ' . $products_price2 . '</span><br><span class="our">our price ' . $products_price . '</span><br>';
  11. $save1 = ($c2 - $c1); 
  12. $save = (($c2 - $c1) / $c2 ) * 100;
  13. $save = round($save);
  14. echo '<span class="save">you save Ł' . $save1 . ' or ' . $save . '% of RRP</span>';
  15.  
  16. } else {
  17.  
  18. $c1 = $saveprice->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id']));
  19. $c2 = $saveprice->display_price($product_info['products_price2'], tep_get_tax_rate($product_info['products_tax_class_id']));
  20. echo '<span class="rrp">RRP ' . $products_price2 . '</span><br><span class="our">our price ' . $products_price . '</span><br>';
  21. $save1 = ($c2 - $c1); 
  22. $save = (($c2 - $c1) / $c2 ) * 100;
  23. $save = round($save);
  24. echo '<span class="save">you save Ł' . $save1 . ' or ' . $save . '% of RRP</span>';
  25. }
  26. //koniec
  27. }
  28. ?>


może sprawdźcie u siebie, bo u mnie nie chce chodzić.
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 18.09.2025 - 17:22