Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Problem ze formularzem i foreach, w skrypcie wyswietlającym produkty
Rahman
post
Post #1





Grupa: Zarejestrowani
Postów: 20
Pomógł: 0
Dołączył: 10.01.2008

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


Witam

Chciałem na swojej stronie zrobić panelik do wyświetlanie produktow z danej kategorii i/lub dyscypliny.
(robię taki mini sklepik sportowy) i mam mały dylemat ze skryptem.

Może najpierw forma w html:

  1. <form id="frmPokaz" action="pokaz.php" method="get" >
  2. <fieldset id="Pokaz"><legend>Wybierz swoja kategorie</legend>
  3. <table id="tblPokaz" >
  4. <tr>
  5. <td class="underline">Dyscyplina:</td>
  6. <td>
  7. <select name="dyscyplina" id="select">
  8. <option selected value="0"><strong>Wszystkie</strong></option>
  9. <option value="1">Koszykówka</option>
  10. <option value="2">Pilka Nozna</option>
  11. <option value="3">Sztuki walki</option>
  12. <option value="4">Lekkoatletyka</option>
  13. <option value="5">Siatkówka</option>
  14. <option value="6">Futbol Amerykański</option>
  15. <option value="7">Suplementy</option>
  16. </select> </td>
  17. <td class="underline">Kategoria:</td>
  18. <td>Odziez</td>
  19. <td><input name="kategoria" type="checkbox" class="checkbox" value="1"/></td>
  20. <td>Sprzet</td>
  21. <td><input name="kategoria" type="checkbox" class="checkbox" value="2"/></td>
  22. <td>Inne</td>
  23. <td><input name="kategoria" type="checkbox" class="checkbox" value="3"/></td>
  24. <td><input type="submit" class="submit" name="submit" id="pokaz" value="Pokaz"></td>
  25. </tr>


Skrypt:

  1. <?php
  2.  
  3. require_once ("include/polaczenie.php");
  4.  
  5.  
  6.  
  7. foreach ($_GET['kategoria'] as $pt) { 
  8.  $in1 .= "'" . $pt . "',"; 
  9.  
  10.  }
  11. $in1 = substr($in1,0,strlen($pt)-1); 
  12.  
  13. $sql = "SELECT ID_prod, ID_kat, ID_dyscyplina, nazwa_prod, cena, dostepny, opis_pro
    d
  14.  FROM produkty WHERE ID_kat IN (" . $in1 . ") AND ID_dyscyplina=" . $_GET['dyscyplina'] . ");";
  15. //echo $sql;
  16.  
  17. $query = mysql_query($sql);
  18.  
  19. $query = mysql_query($sql) or die(mysql_error());
  20. if(mysql_num_rows($query) > 0) 
  21. {
  22.  
  23. while ($row = mysql_fetch_assoc($query)) 
  24.  { 
  25.  echo '<p class="p_szukaj_php">',$row['nazwa_prod'],'</p> 
  26.  <table class="szukaj_php" cellpadding="5">
  27. <tr>
  28. <td rowspan="2" valign="top" align="left" cellpadding="5"><img src="images/img_male/',$row['ID_prod'],'.jpg"/> </td>
  29. <td colspan="4" valign="top" width="400" align="left">',$row['opis_prod'],'</td>
  30. </tr>
  31. <tr>
  32. <td align="left" valign="top">Cena: ',$row['cena'],'</td>
  33.  
  34.  
  35.  <td align="left" valign="top">Dostepny: ',$row['dostepny'],'</td>
  36.  <td align="left" valign="top"><a href="opinie.php"><input type="submit" class="submit" value="Opinie"></a></a></td>
  37.  <td align="left" valign="top" align="right"><a href=""><input type="submit" class="submit" value="Do Koszyka"></a></td>
  38.  </tr>
  39. </table>
  40. <p class="p_szukaj_php"></p>';
  41.  
  42. }
  43. }
  44. ?>


I pluje mi takim błędem:

[b]
  1. <?php
  2. Warning[/b]: Invalid argument supplied for foreach() in [b]C:WebServhttpdRunners2pokaz.php[/b] on line [b]213[/b]
  3. Something is wrong in your syntax obok ') AND ID_dyscyplina=)' w linii 2
  4. ?>


Nie wiem co jest grane już.
Pomoże ktoś?


Pozdrawiam
Powód edycji: dodałem tag i zmodyfikowałem temat (cysiaczek)
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: 20.09.2025 - 10:34