Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Wpisy do bazy dodają się nie po kolei
kamil1114
post
Post #1





Grupa: Zarejestrowani
Postów: 117
Pomógł: 0
Dołączył: 22.02.2008
Skąd: katowice

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


Mam taki problem ,że wpisy do bazy danych dodają się nie po kolei , co skutkuje wyświetlaniem komentarzy w niepoprawnej kolejności. Nie jestem pewien , ale wydaje mi się że dzieje się tak odkąd dodałem skrypt wyświetlania emoitek.

Tutaj zamieszczam kod:
  1. <?php
  2. if(isset($_GET['id'])){
  3. $id=$_GET['id'];
  4. mysql_connect('serwer','login','haslo');
  5.  
  6.  
  7. $wyswietl=mysql_query("select * from newsy where id='$id'");
  8.  
  9. while($i=mysql_fetch_assoc($wyswietl)){
  10.  
  11. $tytul=$i['tytul'];
  12. $tresc=$i['tresc'];
  13. $data=$i['data'];
  14.  
  15. echo "<div align='right'><img src='./cal.gif'></img> $data</div>";
  16. echo "<h2><center><dig style='color:olivedrab'>$tytul </div></center></h2><br/><br/>";
  17. echo "$tresc<br/><br/><hr color='olivedrab'/>";
  18.  
  19. }
  20.  
  21. echo "<br/><br/>";
  22. echo "<center><img src='./kom.gif' alt='komentarze'></center>";
  23. $kom=mysql_query("select * from komentarze where id_newsa='$id'");
  24. while($a=mysql_fetch_assoc($kom)){
  25.  
  26.  
  27. $nick=$a['nick'];
  28. $tresc1=$a['tresc'];
  29. $ip=$a['ip'];
  30.  
  31.  
  32. $tresc1=str_replace(":)","<img src='./emotki/dwukropek).gif'></img>",$tresc1);
  33. $tresc1=str_replace(":(","<img src='./emotki/dwukropek(.gif'></img>",$tresc1);
  34. $tresc1=str_replace(";p","<img src='./emotki/;p.gif'></img>",$tresc1);
  35. $tresc1=str_replace(";]","<img src='./emotki/;].gif'></img>",$tresc1);
  36. $tresc1=str_replace("^_^","<img src='./emotki/^_^.gif'></img>",$tresc1);
  37.  
  38.  
  39. echo "<b>$nick</b>";
  40. echo "<b> : </b>";
  41. echo "$tresc1";
  42. echo "<br/><hr size=3/>";
  43. }
  44.  
  45.  
  46. echo "<br/><br/><br/><hr/><br/><center>";
  47. echo "<b>Dodawanie komentarzy:</b></br>";
  48.  
  49. echo "<form method='post'>";
  50.  
  51. echo "Twój nick: </br>";
  52.  
  53. echo "<input type='text' name='nick'> </br>";
  54.  
  55. echo "Tresć komentarza: </br>";
  56.  
  57. echo "<textarea name='komentarz' cols='40' rows='15'></textarea> </br>";
  58.  
  59. echo "<input type='submit' value='Dopisz'>";
  60.  
  61. echo "</form>";
  62. echo "</center>";
  63.  
  64. $nick=strip_tags($_POST['nick']);
  65. $text=nl2br(strip_tags($_POST['komentarz']));
  66. $ip=$_SERVER['REMOTE_ADDR'];
  67.  
  68.  
  69. if(!empty($nick) && !empty($tresc)){
  70. $id_newsa=$_GET['id'];
  71. mysql_query("insert into komentarze (id,nick,tresc,ip,id_newsa) values (0,'$nick','$text','$ip','$id_newsa')");
  72.  
  73. echo '<script type="text/javascript">
  74. window.location.href = "index1.php";
  75. </script>';
  76.  
  77. }
  78.  
  79.  
  80. }
  81. ?>


Proszę o pomoc. Co jest nie tak ?

Ten post edytował kamil1114 23.12.2009, 21:43:11
Go to the top of the page
+Quote Post

Posty w temacie


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 Aktualny czas: 20.08.2025 - 14:47