Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [MySQL][PHP]optymalizacja kodu/skrocenie kodu
Michał90
post
Post #1





Grupa: Zarejestrowani
Postów: 267
Pomógł: 0
Dołączył: 16.05.2007

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


Witam,
Czy da się taki kod skrócić ?

  1. while ($row = mysql_fetch_assoc($query))
  2. {
  3. if($row['test'] == '103')
  4. {
  5. echo '<li><a href="' . $siteurl . 'kat/akc/1/">' . $row['name'] . '</a></li>';
  6. }
  7. else if ($row['test'] == '106')
  8. {
  9. echo '<li><a href="' . $siteurl . 'kat/ar/1/">' . $row['name'] . '</a></li>';
  10. }
  11. else if($row['test'] == '104')
  12. {
  13. echo '<li><a href="' . $siteurl . 'kat/inne/1/">' . $row['name'] . '</a></li>';
  14. }
  15. else if($row['test'] == '111')
  16. {
  17. echo '<li><a href="' . $siteurl . 'kat/kas/1/">' . $row['name'] . '</a></li>';
  18. }
  19. else if($row['test'] == '120')
  20. {
  21. echo '<li><a href="' . $siteurl . 'kat/kol/1/">' . $row['name'] . '</a></li>';
  22. }
  23. else if($row['test'] == '100')
  24. {
  25. echo '<li><a href="' . $siteurl . 'kat/puz/1/">' . $row['name'] . '</a></li>';
  26. }
  27. else if($row['test'] == '110')
  28. {
  29. echo '<li><a href="' . $siteurl . 'kat/rex/1/">' . $row['name'] . '</a></li>';
  30. }
  31. else if($row['test'] == '101')
  32. {
  33. echo '<li><a href="' . $siteurl . 'kat/sp/1/">' . $row['name'] . '</a></li>';
  34. }
  35. else if($row['test'] == '105')
  36. {
  37. echo '<li><a href="' . $siteurl . 'kat/st/1/">' . $row['name'] . '</a></li>';
  38. }
  39. else if($row['test'] == '108')
  40. {
  41. echo '<li><a href="' . $siteurl . 'kat/wal/1/">' . $row['name'] . '</a></li>';
  42. }
  43. else if($row['test'] == '109')
  44. {
  45. echo '<li><a href="' . $siteurl . 'kat/wy/1/">' . $row['name'] . '</a></li>';
  46. }
  47.  
  48. else{
  49. echo '<li><a href="' . $siteurl . 'kat/' . $row['test'] .'/1/">' . $row['name'] . '</a></li>';
  50. }
  51. }


Pozdrawiam
Go to the top of the page
+Quote Post

Posty w temacie


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 Aktualny czas: 19.08.2025 - 16:18