Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP][MYSQL]Problem z filtracja
mczlowiek
post 10.07.2008, 09:24:02
Post #1





Grupa: Zarejestrowani
Postów: 210
Pomógł: 0
Dołączył: 26.05.2008

Ostrzeżenie: (10%)
X----


Oto fragment kodu:
  1. <?php
  2.  
  3. if (isset($_POST['username'])) { 
  4.  
  5. $query="SELECT * FROM typy WHERE autor=$_POST[username]";
  6. $result=mysql_query($query)
  7. or die(mysql_error());
  8.  
  9. echo '<table>';
  10. echo '<tr>';
  11.  
  12. echo '<td width=100>';
  13. echo '<form action="typy_new.php" method="post"><input type="submit" name="submit" value="Dodaj typ"></form>';
  14. echo '</td>';
  15. echo '</tr>';
  16. echo '<tr>';
  17. echo '<td>';
  18. echo '<form action="typy_filtruj.php" method="post">';
  19. $sql=mysql_query("SELECT id, username FROM admin order by username");
  20.  
  21.  echo '<select name="username">';
  22.  
  23.  while ($row=mysql_fetch_array($sql))
  24.  {
  25.  echo "<option value=$row[id]>$row[username]</option>";
  26.  }
  27.  echo "</select>";
  28. echo '<input type="submit" name="submit" value="Filtruj">';
  29. echo '</form><br><br>';
  30. echo '</td>';
  31. echo '</tr>';
  32. echo '</table>';
  33.  
  34. <!--WYSWIETLANIE WYNIKOW-->
  35.  
  36. echo ("<table border=1 width=690>");
  37. echo ("<tr>");
  38. echo ("<td width=40>");
  39. echo '<font face="Verdana" size="1" color="white">';
  40. echo 'Data';
  41. echo '</font>';
  42. echo ("</td>");
  43.  
  44. echo ("<td width=100>");
  45. echo '<font face="Verdana" size="1" color="white">';
  46. echo 'Autor';
  47. echo '</font>';
  48. echo ("</td>");
  49.  
  50. echo ("<td width=320>");
  51. echo '<font face="Verdana" size="1" color="white">';
  52. echo 'Spotkanie';
  53. echo '</font>';
  54. echo ("</td>");
  55.  
  56. echo ("<td width=20>");
  57. echo '<font face="Verdana" size="1" color="white">';
  58. echo 'Typ';
  59. echo '</font>';
  60. echo ("</td>");
  61.  
  62. echo ("<td width=20>");
  63. echo '<font face="Verdana" size="1" color="white">';
  64. echo 'Kurs';
  65. echo '</font>';
  66. echo ("</td>");
  67.  
  68. echo ("<td width=20>");
  69. echo '<font face="Verdana" size="1" color="white">';
  70. echo 'Stawka';
  71. echo '</font>';
  72. echo ("</td>");
  73.  
  74. echo ("<td width=40>");
  75. echo '<font face="Verdana" size="1" color="white">';
  76. echo 'wynik';
  77. echo '</font>';
  78. echo ("</td>");
  79.  
  80. echo ("<td width=30>");
  81. echo '<font face="Verdana" size="1" color="white">';
  82. echo 'profit';
  83. echo '</font>';
  84. echo ("</td>");
  85.  
  86. echo ("<td width=50>");
  87. echo '<font face="Verdana" size="1" color="white" >';
  88. echo 'Edytuj';
  89. echo '</font>';
  90. echo ("</td>");
  91.  
  92. echo ("<td width=50>");
  93. echo '<font face="Verdana" size="1" color="white">';
  94. echo 'Usuń';
  95. echo '</font>';
  96. echo ("</td>");
  97. echo ("</tr");
  98.  
  99. while ($row = mysql_fetch_array($result)) {
  100. echo ("<tr>");
  101. echo ("<td width=20>");
  102. echo '<font face="Verdana" size="1" color="white">';
  103. echo $row['data'];
  104. echo '</font>';
  105. echo ("</td>");
  106.  
  107. echo ("<td width=50>");
  108. echo '<font face="Verdana" size="1" color="white">';
  109. echo $row['autor'];
  110. echo '</font>';
  111. echo ("</td>");
  112.  
  113. echo ("<td width=250>");
  114. echo '<font face="Verdana" size="1" color="white">';
  115. echo $row['spotkanie'];
  116. echo '</font>';
  117. echo ("</td>");
  118.  
  119. echo ("<td width=10>");
  120. echo '<font face="Verdana" size="1" color="white">';
  121. echo $row['typ'];
  122. echo '</font>';
  123. echo ("</td>");
  124.  
  125. echo ("<td width=15>");
  126. echo '<font face="Verdana" size="1" color="white">';
  127. echo $row['kurs'];
  128. echo '</font>';
  129. echo ("</td>");
  130.  
  131. echo ("<td width=15>");
  132. echo '<font face="Verdana" size="1" color="white">';
  133. echo $row['stawka'];
  134. echo '</font>';
  135. echo ("</td>");
  136.  
  137. echo ("<td width=20>");
  138. echo '<font face="Verdana" size="1" color="white">';
  139. echo $row['wynik'];
  140. echo '</font>';
  141. echo ("</td>");
  142.  
  143. echo ("<td width=20>");
  144. echo '<font face="Verdana" size="1" color="white">';
  145. echo $row['profit'];
  146. echo '</font>';
  147. echo ("</td>");
  148.  
  149. echo ("<td width=50>");
  150. echo '<font face="Verdana" size="1" color="white" >';
  151. echo '<a href="typy_view.php?id='.$row['id'].'" style="text-decoration: none" title="edytuj"><font face="Verdana" size="1" color="white" >Edytuj</a>';
  152. echo '</font>';
  153. echo ("</td>");
  154.  
  155. echo ("<td width=50>");
  156. echo '<font face="Verdana" size="1" color="white">';
  157. echo '<a href="typy_delete.php?id='.$row['id'].'" style="text-decoration: none" title="usun"><font face="Verdana" size="1" color="white" >Usuń</a>';
  158. echo '</font>';
  159. echo ("</td>");
  160. echo ("</tr");
  161.  
  162.  
  163. }
  164. echo ("</table>");
  165. } else {
  166. echo 'brak uzytkownika';
  167. }
  168. ?>

kiedy z listy rozwijanej wybieram uzytkownika powinny swyswieltic mi sie tylko jego tematu(uzytkownika) jednak nic sie nie wyswietla, dlacego mimo ze w bazie ma (uzytkownik ) wpisy
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 5)
Lejto
post 10.07.2008, 09:33:49
Post #2





Grupa: Zarejestrowani
Postów: 1 385
Pomógł: 48
Dołączył: 23.05.2007

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


zmień to zapytanie, może $_POST masz pustą
  1. $query="SELECT * FROM typy WHERE autor='".$_POST['username']."'";


--------------------
Go to the top of the page
+Quote Post
piotrooo89
post 10.07.2008, 09:38:53
Post #3


Newsman


Grupa: Moderatorzy
Postów: 4 005
Pomógł: 548
Dołączył: 7.04.2008
Skąd: Trzebinia/Kraków




lepiej tak:
  1. "SELECT * FROM typy WHERE autor='$_POST['username']'";


Ten post edytował piotrooo89 10.07.2008, 09:39:07


--------------------
Go to the top of the page
+Quote Post
mczlowiek
post 10.07.2008, 10:11:19
Post #4





Grupa: Zarejestrowani
Postów: 210
Pomógł: 0
Dołączył: 26.05.2008

Ostrzeżenie: (10%)
X----


niestety nic nie pomaga...

a może tutaj jest jakiś błąd, że pobiera id a nie username, ale tylko strzelam bo za bardzo sie nie znam..
  1. <?php
  2. while ($row=mysql_fetch_array($sql))
  3.  {
  4.  echo "<option value=$row[id]>$row[username]</option>";
  5.  }
  6. ?>
Go to the top of the page
+Quote Post
_olo_1984
post 10.07.2008, 10:17:42
Post #5





Grupa: Zarejestrowani
Postów: 289
Pomógł: 77
Dołączył: 5.08.2006

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


  1. <?php
  2. while ($row=mysql_fetch_array($sql))
  3.  {
  4.  echo '<option value="'.$row['id'].'">'.$row['username'].'</option>';
  5.  }
  6. ?>


a nuż smile.gif


--------------------
awake
Go to the top of the page
+Quote Post
mczlowiek
post 10.07.2008, 10:32:39
Post #6





Grupa: Zarejestrowani
Postów: 210
Pomógł: 0
Dołączył: 26.05.2008

Ostrzeżenie: (10%)
X----


juz mam smile.gif
  1. <?php
  2. echo '<option value="'.$row['username'].'">'.$row['username'].'</option>';
  3. ?>
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 - 02:59