Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> problem z updatowaniem kolumn z pziomu php
SoulRipper
post
Post #1





Grupa: Zarejestrowani
Postów: 86
Pomógł: 0
Dołączył: 15.03.2003
Skąd: lodz

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


mam takie oto cos:
  1. <?
  2. $query = &#092;"select * from art where id='$ajdi'\";
  3.  
  4. $commit = mysql_query($query);
  5. $fetch = mysql_fetch_array($commit);
  6. $id=$fetch['id'];
  7. $autor=$fetch['autor'];
  8. $art=$fetch['art'];
  9.  
  10. echo &#092;"
  11.  
  12. <form method='post' action='modify.php'>
  13. Autor<input type='text' name='autor' value='$autor'><br>
  14. ID artykolu<input type='text' name='id' value='$ajdi' disabled><br>
  15. <textarea name='art' cols='60' rows='40'>$art</textarea><br>
  16. <input type='submit' name='go' value='dalej'>
  17.  
  18. </form>&#092;";
  19.  
  20. $button = $_POST['go'];
  21. $art = $_POST['art'];
  22. $autor = $_POST['autor'];
  23. if($button == &#092;"dalej\")
  24. {
  25.  
  26. $query = &#092;"updade art set art='qwewerewr' \";
  27. $result = mysql_query ($query);
  28. echo $art.&#092;"<br>\".$autor.\"<br>\".$ajdi.\"<br>\".mysql_affected_rows();
  29.  
  30. }
  31. ?>


problem polega na tym ze nie chce dzialac zapytanie update
caly scrypt polega na pobieraniu z bazy danych wartosci art oraz autor a nastepnie wyswietleniu ich w odpowiednich polach tekstowych, pozniej nacisniecie przycisku 'dalej' powinno updatowac kolumne art oraz kolumne autor o okreslonym id o te wartosci wpisane w pola tekstowe

ps.
polaczenie z baza danych jest zapisana w innym pliku ktory jest polaczony z tym
za pomoca funkcji include

Ten post edytował SoulRipper 16.10.2004, 09:43:05
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
SoulRipper
post
Post #2





Grupa: Zarejestrowani
Postów: 86
Pomógł: 0
Dołączył: 15.03.2003
Skąd: lodz

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


dobra jeden problem rozwiazny, teraz rodzi sie inny pomimo tego ze jest przypisana zmienna do $id potrzebna w zapytaniu:
  1. <?php
  2.  
  3. $query = &#092;"update art set art='$art' and autor='$autor' where id='$id' \";
  4.  
  5. ?>

problem polega na tym ze mysql)affected_rows() wyswietla 0
wnioskuje z tego ze nie moze odnalesc tej zmiennej $id.

a oto kompletny kod

  1. <?
  2. include &#092;"include.php\" ;
  3.  
  4. //kod odpowiedzialny za zmiane id modyfikowanego formularza
  5. $zmien_id = $_POST['change_id'];
  6. $button_klik = $_POST['zmiana'];
  7. if ($button_klik == &#092;"go\")
  8. {
  9.     $ajdi = $zmien_id;
  10. }
  11. //kod odpowiedzailny za modyfikowanie wpisow
  12.  
  13. $query = &#092;"select * from art where id='$ajdi'\";
  14.  
  15. $commit = mysql_query($query);
  16. $fetch = mysql_fetch_array($commit);
  17. $id=$fetch['id'];
  18. $autor=$fetch['autor'];
  19. $art=$fetch['art'];
  20.  
  21. echo &#092;"
  22.     
  23.     <form method='post' action='modify.php'>
  24.     Autor<input type='text' name='autor' value='$autor'><br>
  25.     ID artykolu<input type='text' name='id' value='$ajdi' disabled><br>
  26.     <textarea name='art' cols='60' rows='40'>$art</textarea><br>
  27.     <input type='submit' name='go' value='dalej'>
  28.         
  29.     </form>&#092;";
  30.  
  31. $button = $_POST['go'];
  32. $art = $_POST['art'];
  33. $autor = $_POST['autor'];
  34. if($button == &#092;"dalej\")
  35. {
  36.  
  37.     $query = &#092;"update art set art='$art' and autor='$autor' where id='$id' \";
  38.     $result = mysql_query ($query);
  39.     echo $art.&#092;"<br>\".$autor.\"<br>\".$ajdi.\"<br>\".mysql_affected_rows();
  40.  
  41. }
  42.  
  43.  
  44. ?>
  45.  
  46. <form method=\"post\" action=\"modify.php\">
  47. <br>skocz do ID artykolu:<input type=\"text\" name=\"change_id\" size=\"3\" value=\"<? echo $id; ?>\"><br>
  48. <input type=\"submit\" name=\"zmiana\" value=\"go\">
  49. </form>
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: 11.10.2025 - 18:03