Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> System newsów..., Drobny błąd z działaniem
Isaac
post 31.10.2005, 13:08:55
Post #1





Grupa: Zarejestrowani
Postów: 6
Pomógł: 0
Dołączył: 23.09.2005

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


Witam. Wraz z znajomym napisaliśmy prosty system newsów wyświetlający ostatnie newsy na stronie. Natomiast natknęliśmy się na problem dotyczący nie działąnia funkcji wyświetlającej "czytaj więcej". Jeśli znajdziecie jakieś błędy w poniższym kodzie proszę o w miarę szybką odpowiedz. Skrypt powinien wg funkcji get na stronie index.php?news=readmore&id=$id wyświetlić całego danego newsa, natoiast nic z tym nie robi.

  1. <?
  2.  
  3. $query="select nick, tytul, small_news, all_news, obraz, data, mail, zrodlo, id from news order
     by id desc"
    ;
  4. $result=mysql_db_query($baza, $query);
  5. $i=1;
  6. while ($offdata = mysql_fetch_array ($result))
  7.  {
  8. $nick = $offdata['0'];
  9. $title = $offdata['1'];
  10. $small_text = $offdata['2'];
  11. $all_text = $offdata['3'];
  12. $obraz = $offdata['4'];
  13. $data = $offdata['5'];
  14. $mail = $offdata['6'];
  15. $zrodlo = $offdata['7'];
  16. $id = $offdata['8'];
  17.  
  18.  
  19.  $str=substr("$offdata[2]", 0, 1);
  20.  $tresc ="offdata[2]";
  21.  $rest = strtolower($str);
  22.  $str2=substr("$offdata[2]", 1);
  23.  $img=("<img src='$obraz' border='0' style='width: 100px' align='right' />");
  24.  if($i<=5){  
  25. $news_top = "<table colspan="0" class="news" cellspacing="0" cellpadding="0">
  26. <tbody>
  27. <tr>
  28. <td class="news_title" colspan="10"><br />
  29. <br />
  30. <div>$title</div></td>
  31. </tr>
  32.  
  33. <tr>
  34. <td class="news_txt">
  35. <br />
  36. <table class="table2">
  37. <tr><td class="txt">
  38.  
  39. $img
  40. ";
  41. $news_bottom = "</td></tr>
  42. </table>
  43. <br />
  44.  
  45. </p>
  46. <div class="news_i" style="text-align: left"><br />
  47. Dodał:&nbsp;&nbsp;<a class="link_news" href="mailto:$mail?subject= Nordmar Kingdom - news">$nick</a>,&nbsp;&nbsp;dnia&nbsp;&nbsp;$data&nbsp;&nbsp;
  48.  
  49. </div><br />
  50. </td>
  51. </tr>
  52.  
  53. <tr>
  54. <td class="news_bottom" colspan="10"></p></td>
  55. </tr>
  56. </tbody>
  57. </table><br />";
  58.  
  59.  
  60.  
  61.  
  62. if($all_text=='')
  63. {
  64. $all_text=='';
  65. echo("$news_top $small_text $news_bottom");
  66. }
  67. else
  68. {
  69.  
  70. $all_text = "<a href="news=readmore&id=$id" class="link_news">więcej...</a>";
  71.  
  72. echo("$news_top $small_text 
  73.  
  74. </td></tr>
  75. </table>
  76. <br />
  77.  
  78. </p>
  79. <div class="news_i" style="text-align: left"><br />
  80. Dodał:&nbsp;&nbsp;<a class="link_news" href="mailto:$mail?subject= Nordmar Kingdom - news">$nick</a>,&nbsp;&nbsp;dnia&nbsp;&nbsp;$data&nbsp;&nbsp;$all_text
  81.  
  82. </div><br />
  83. </td>
  84. </tr>
  85.  
  86. <tr>
  87. <td class="news_bottom" colspan="10"></p></td>
  88. </tr>
  89. </tbody>
  90. </table><br />
  91. ");
  92. }
  93. $i++;
  94. }}
  95.  
  96.  
  97.  
  98.  
  99. if ($_GET[news]=="readmore")
  100. {
  101. $query = "select nick, tytul, all_news, obraz, data, mail, zrodlo, id from news WHERE id='$_GET[id]'";
  102. $result = mysql_query($baza, $query);
  103.  
  104. while ($offdata = mysql_fetch_array ($result))
  105. {
  106. $nick = $offdata['0'];
  107. $title = $offdata['1'];
  108. $all_text = $offdata['2'];
  109. $obraz = $offdata['3'];
  110. $data = $offdata['4'];
  111. $mail = $offdata['5'];
  112. $zrodlo = $offdata['6'];
  113. $id = $offdata['7'];
  114.  
  115. $news_top = "<table colspan="0" class="news" cellspacing="0" cellpadding="0">
  116. <tbody>
  117. <tr>
  118. <td class="news_title" colspan="10"><br />
  119. <br />
  120. <div>$title</div></td>
  121. </tr>
  122.  
  123. <tr>
  124. <td class="news_txt">
  125. <br />
  126. <table class="table2">
  127. <tr><td class="txt">
  128.  
  129. $img
  130. ";
  131. $news_bottom = "</td></tr>
  132. </table>
  133. <br />
  134.  
  135. </p>
  136. <div class="news_i" style="text-align: left"><br />
  137. Dodał:&nbsp;&nbsp;<a class="link_news" href="mailto:$mail?subject= site">$nick</a>,&nbsp;&nbsp;dnia&nbsp;&nbsp;$data&nbsp;&nbsp;
  138.  
  139. </div><br />
  140. </td>
  141. </tr>
  142.  
  143. <tr>
  144. <td class="news_bottom" colspan="10"></p></td>
  145. </tr>
  146. </tbody>
  147. </table><br />";
  148.  
  149. echo '$news_top $all_text $news_bottom';
  150. }
  151. }
  152.  
  153.  
  154.  
  155. ?>



~mike_mech

Ten post edytował Isaac 31.10.2005, 15:21:14
Go to the top of the page
+Quote Post
nospor
post 31.10.2005, 18:27:03
Post #2





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




linia 21:
$tresc ="offdata[2]";
tu masz blad i moze gdzies jeszcze. chyba juz wiesz jaki. Na przyszlosc nie dawaj takich tematow, bo beda zamykane. tu nie odwalamy za nikogo poprawy literowek.


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

"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: 15.07.2025 - 04:48