Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP][MYSQL]Edycja rekordów
Matax
post
Post #1





Grupa: Zarejestrowani
Postów: 4
Pomógł: 0
Dołączył: 23.12.2008

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


Mam problem ze skryptem edycji rekordów w bazie danych. Skrypt można znaleźć tutaj : TU
A mianowicie wszystko wygląda OK, lecz rekord nie chce się zaktualizować. Oto kod :
  1. <?php
  2.  
  3. include('config.php'); //plik gdzie mam połączenie z bazą
  4.  
  5.  
  6. $query = "select * from Koment order by ID DESC limit 0,10";
  7. $result = mysql_query($query);  
  8. $num_results = mysql_num_rows($result);  
  9.  
  10. print "<br>";
  11.  
  12.  
  13.  
  14. print "<p>Ilossć komentarzy w bazie danych: ".$num_results."</p>";  
  15. for ($i=0; $i <$num_results; $i++)  {  
  16.    $row = mysql_fetch_array($result);    
  17.    print ($i+1).". ";  
  18.    print $row['ID'];
  19.    print ",<font color=red> user: </font>";    
  20.    print stripslashes($row["user"]);    
  21.    print "<font color=green> koment: </font>";
  22.    print stripslashes($row["koment"]);  
  23.    print "&nbsp&nbsp";
  24.    print "<a href=http://testow.cba.pl/edytuj.php?akcja=edytuj&id=".$row['ID'].">Edytuj</a>";
  25.    print "<br>";
  26. }
  27.  
  28. print "<br>";
  29.  
  30. print $_GET['akcja'];
  31. print "<br>";
  32. print $_GET['id'];
  33.  
  34.  
  35. if ($_GET['akcja']=="edytuj")
  36. {
  37.  
  38. $query2 = "select koment from Koment where ID=".$_GET['id'];
  39. $result2 = mysql_query($query2);  
  40. $array=mysql_fetch_array($result2);
  41.  
  42. print "<form action=edytuj.php?akcja=wyedytuj&id=".$_GET['id']." method=POST>";
  43. print "<textarea cols=60 rows=10 name=koment>";
  44. print $array['koment'];
  45.  
  46. print "</textarea>";
  47. print "<input type=submit value=edytuj>";
  48. print "</form>";
  49.  
  50. }
  51.  
  52. elseif ($_GET['akcja']=="wyedytuj")
  53. {
  54.  
  55. $query3="UPDATE Koment SET koment=".$_POST['koment']." where ID=".$_GET['id'];
  56. $edyt=mysql_query($query3);
  57.  
  58. if ($edyt)
  59. {
  60. print "Edycja poprawna";
  61. }
  62.  
  63. }
  64. ?>



Wyświetla poprawnie, formularz edycji również poprawnie lecz nie chce się wyedytować. Pomocy!

Ten post edytował Matax 23.12.2008, 19:11:48
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: 23.08.2025 - 20:03