Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [MySQL][PHP]Update bazy danych - problem ze zmiana, Problem ze zmianami.
szczalpi
post 25.06.2013, 12:55:13
Post #1





Grupa: Zarejestrowani
Postów: 336
Pomógł: 0
Dołączył: 25.10.2006

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


Witam
Poniżej podaje jak mam kod do update bazy. Otóż to. Pobiera mi wszystkie dane z bazy, ale niestety nie zmienia wpisów, które edytowałem.
NIe wiem gdzie tkwi problem. Czy możecie pomóc mi i zobaczyć gdzie tkwi problem.
Pozdrawiam
  1. $pokaz = $_GET['pokaz'];
  2.  
  3. $sql="select * from atrakcje where id='$pokaz'";
  4. $result=mysql_query($sql);
  5. $row=mysql_fetch_array($result);
  6.  
  7. if(isset($_GET['changes'])):
  8. {
  9.  
  10. $id = $_GET['id'];
  11. $kat = $_GET['kat'];
  12. $tytul =$_GET['tytul'];
  13. $ul = $_GET['ul'];
  14. $miasto = $_GET['miasto'];
  15. $gmina = $_GET['gmina'];
  16. $powiat = $_GET['powiat'];
  17. $wojewodztwo = $_GET['wojewodztwo'];
  18. $opis = $_GET['opis'];
  19. $www = $_GET['www'];
  20. $zdjecie = $_GET['zdjecie'];
  21. $gmx = $_GET['gmx'];
  22. $gmy = $_GET['gmy'];
  23. $counter = $_GET['counter'];
  24.  
  25. $sql="update atrakcje set id='$id' where id='$pokaz'";
  26. mysql_query($sql);
  27.  
  28. $sql="update atrakcje set kat='$kat' where id='$pokaz'";
  29. mysql_query($sql);
  30.  
  31. $sql="update atrakcje set tytul='$tytul' where id='$pokaz'";
  32. mysql_query($sql);
  33.  
  34. $sql="update atrakcje set ul='$ul' where id='$pokaz'";
  35. mysql_query($sql);
  36.  
  37. $sql="update atrakcje set miasto='$miasto' where id='$pokaz'";
  38. mysql_query($sql);
  39.  
  40. $sql="update atrakcje set gmina='$gmina' where id='$pokaz'";
  41. mysql_query($sql);
  42.  
  43. $sql="update atrakcje set powiat='$powiat' where id='$pokaz'";
  44. mysql_query($sql);
  45.  
  46. $sql="update atrakcje set wojewodztwo='$wojewodztwo' where id='$pokaz'";
  47. mysql_query($sql);
  48.  
  49. $sql="update atrakcje set opis='$opis' where id='$pokaz'";
  50. mysql_query($sql);
  51.  
  52. $sql="update atrakcje set www='$www' where id='$pokaz'";
  53. mysql_query($sql);
  54.  
  55. $sql="update atrakcje set zdjecie='$zdjecie' where id='$pokaz'";
  56. mysql_query($sql);
  57.  
  58. $sql="update atrakcje set gmx='$gmx' where id='$pokaz'";
  59. mysql_query($sql);
  60.  
  61. $sql="update atrakcje set gmy='$gmy' where id='$pokaz'";
  62. mysql_query($sql);
  63.  
  64. $sql="update atrakcje set counter='$counter' where id='$pokaz'";
  65. mysql_query($sql);
  66.  
  67.  
  68. echo "<p align=\"center\">Twoje dane zostały zmienione.</p>";
  69. echo $row['id'];
  70. }
  71. else:
  72. {
  73. ### wyœwietlenie wpisu #######################################################?>
  74. <form action="edycja.php" method="get">
  75. <table width=450 align="center">
  76. <tr><td align="center" height=0><p>Tutaj możesz zmienić i aktualizować swoje dane:</table>
  77.  
  78. <table width="750" align="center">
  79. <tr>
  80. <td>&nbsp;
  81. <tr>
  82. <td class="label">Kategoria:</td><td><input class="long" type="text" name="id" value="<? echo $row['id']; ?>">
  83. </tr><br/>
  84. <tr>
  85. <td class="label">Kategoria:</td><td><input class="long" type="text" name="kat" value="<? echo $row['kat']; ?>">
  86. </tr><br/>
  87. <tr>
  88. <td class="label">Tytul:</td><td><input class="long" type="text" name="tytul" value="<? echo $row['tytul']; ?>">
  89. </tr><br/>
  90. <tr>
  91. <td class="label">Ulica:</td><td><input class="long" type="text" name="ul" size="40" value="<? echo $row['ul']; ?>">
  92. </tr><br/>
  93.  
  94. <tr>
  95. <td class="label">miasto:</td><td><input class="long" type="text" name="miasto" value="<? echo $row['miasto']; ?>">
  96. </tr><br/>
  97. <tr>
  98. <td class="label">gmina:</td><td><input class="long" type="text" name="gmina" value="<? echo $row['gmina']; ?>">
  99. </tr><br/>
  100. <tr>
  101. <td class="label">powiat:</td><td><input class="long" type="text" name="powiat" value="<? echo $row['powiat']; ?>">
  102. </tr><br/>
  103. <tr>
  104. <td class="label">wojewodztwo:</td><td><input class="long" type="text" name="wojewodztwo" value="<? echo $row['wojewodztwo']; ?>">
  105. </tr><br/>
  106. <tr>
  107. <td class="label">opis:</td><td><input class="long" type="text" name="opis" value="<? echo $row['opis']; ?>">
  108. </tr><br/>
  109. <tr>
  110. <td class="label">www:</td><td><input class="long" type="text" name="www" value="<? echo $row['www']; ?>">
  111. </tr><br/>
  112. <tr>
  113. <td class="label">Czdjecie:</td><td><input class="long" type="text" name="zdjecie" value="<? echo $row['zdjecie']; ?>">
  114. </tr><br/>
  115. <tr>
  116. <td class="label">gmx:</td><td><input class="long" type="text" name="gmx" value="<? echo $row['gmx']; ?>">
  117. </tr><br/>
  118. <tr>
  119. <td class="label">gmy:</td><td><input class="long" type="text" name="gmy" value="<? echo $row['gmy']; ?>">
  120. </tr><br/>
  121. <tr>
  122. <td class="label">counter:</td><td><input class="long" type="text" name="counter" value="<? echo $row['counter']; ?>">
  123. </tr><br/>
  124.  
  125. <tr><td><td align="center"><input type="submit" name="changes" value="ok">
  126.  
  127.  
  128. </form>
  129. </table>
  130. <?
  131. }
  132. endif;


--------------------
Nieregulaminowa stopka usunieta
Go to the top of the page
+Quote Post
CuteOne
post 25.06.2013, 13:01:46
Post #2





Grupa: Zarejestrowani
Postów: 2 958
Pomógł: 574
Dołączył: 23.09.2008
Skąd: wiesz, że tu jestem?

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


  1. UPDATE atrakcje SET www='$www', miasto='$miasto', opis='$opis' (itp.) WHERE id='$pokaz'

zamiast 50 zapytań


@edit wiem, wiem. wszystko w swoim czasie wink.gif


@szczapi zobacz jak zapisywać if/else

endif i else: raczej nie pasuje do klamerek smile.gif

Ten post edytował CuteOne 25.06.2013, 13:10:10
Go to the top of the page
+Quote Post
nospor
post 25.06.2013, 13:02:56
Post #3





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




@CuteOne ale wiesz, ze na chwile obecna ta poprawka nic zmieni procz mniejszej ilosci kodu? wink.gif

Co do problemu:
Temat: Jak poprawnie zada pytanie


--------------------

"Myśl, myśl, myśl..." - Kubuś Puchatek || "Manual, manual, manual..." - Kubuś Programista
"Szukaj, szukaj, szukaj..." - Kubuś Odkrywca || "Debuguj, debuguj, debuguj..." - Kubuś Developer

Go to the top of the page
+Quote Post
szczalpi
post 25.06.2013, 13:16:21
Post #4





Grupa: Zarejestrowani
Postów: 336
Pomógł: 0
Dołączył: 25.10.2006

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


  1. $pokaz = $_GET['pokaz'];
  2.  
  3. $sql="select * from atrakcje where id='$pokaz'";
  4. $result=mysql_query($sql);
  5. $row=mysql_fetch_array($result);
  6.  
  7. if(isset($_GET['changes'])):
  8. {
  9.  
  10. $id = $_GET['id'];
  11. $kat = $_GET['kat'];
  12.  
  13.  
  14. $sql="update atrakcje set id='$id' where id='$pokaz'";
  15. mysql_query($sql);
  16.  
  17. $sql="update atrakcje set kat='$kat' where id='$pokaz'";
  18. mysql_query($sql);
  19.  
  20.  
  21.  
  22. echo "<p align=\"center\">Twoje dane zostały zmienione.</p>";
  23. echo $row['id'];
  24. }
  25. else:
  26. {
  27. ### wyœwietlenie wpisu #######################################################?>
  28. <form action="edycja.php" method="get">
  29. <table width=450 align="center">
  30. <tr><td align="center" height=0><p>Tutaj możesz zmienić i aktualizować swoje dane:</table>
  31.  
  32. <table width="750" align="center">
  33. <tr>
  34. <td>&nbsp;
  35. <tr>
  36. <td class="label">Kategoria:</td><td><input class="long" type="text" name="id" value="<? echo $row['id']; ?>">
  37. </tr><br/>
  38. <tr>
  39. <td class="label">Kategoria:</td><td><input class="long" type="text" name="kat" value="<? echo $row['kat']; ?>">
  40. </tr><br/>
  41.  
  42.  
  43.  
  44. <tr><td align="center"><input type="submit" name="changes" value="ok">
  45. </td>
  46. </tr>
  47. </form>
  48. </table>
  49. <?
  50. }
  51. endif;


--------------------
Nieregulaminowa stopka usunieta
Go to the top of the page
+Quote Post
nospor
post 25.06.2013, 13:20:19
Post #5





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




W ogole nie zastosowales sie do tematu do ktorego cie odeslalem..... czego nie zrozumiales?

ps: jak wysylasz forma ze zmianami, to POKAZ tez by wypadalo przeslac ponownie...


--------------------

"Myśl, myśl, myśl..." - Kubuś Puchatek || "Manual, manual, manual..." - Kubuś Programista
"Szukaj, szukaj, szukaj..." - Kubuś Odkrywca || "Debuguj, debuguj, debuguj..." - Kubuś Developer

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: 12.06.2025 - 21:30