Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Prosty system niusów oparty o mySQL.
Mazur_pl
post
Post #1





Grupa: Zarejestrowani
Postów: 87
Pomógł: 0
Dołączył: 11.05.2007

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


Witam, jestem nowy na forum oraz początkującym programistą. (IMG:http://forum.php.pl/style_emoticons/default/guitar.gif)
Napisałem prosty system niusów:
  1. <?php
  2.  
  3. DEFINE ('DB_USER', 'Mazur');
  4. DEFINE ('DB_PASSWORD', '###');
  5. DEFINE ('DB_HOST', 'localhost');
  6. DEFINE ('DB_NAME', 'data');
  7.  
  8. $dbc = mysql_connect (DB_HOST, DB_USER, DB_PASSWORD);
  9. mysql_select_db (DB_NAME);
  10.  
  11. if (isset($_POST['submit'])) {
  12.  
  13. $text = $_POST['news_text'];
  14. $author = $_POST['news_author'];
  15. $topic = $_POST['news_topic'];
  16. $topic_mini = $_POST['news_topic_mini'];
  17.  
  18. if ($author && $text) {
  19.  
  20. $query = "INSERT INTO news (news_text, news_author, news_topic, news_topic_mini)
  21. VALUES
  22. ('$text', '$author', '$topic', '$topic_mini')";
  23.  
  24. $result = mysql_query($query);
  25.  
  26. if ($result) {
  27. echo 'News dodany!';
  28. } else {
  29. }
  30. }
  31. }
  32.  
  33.  
  34. $query = "SELECT * FROM news ORDER BY news_id DESC";
  35.  
  36. $result = mysql_query($query);
  37.  
  38. if ($result) {
  39. while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
  40. echo '<table width="900" align="center" border="1" bordercolor="black" style="border-collapse: collapse;">'."rn";
  41. echo ' <tr>'."rn";
  42. echo '  <td>Tytul: '.$row['news_topic'].'</td>'."rn";
  43. echo ' </tr>'."rn";
  44. echo ' <tr>'."rn";
  45. echo '  <td>Opis: '.$row['news_topic_mini'].'</td>'."rn";
  46. echo ' </tr>'."rn";
  47. echo ' <tr>'."rn";
  48. echo '  <td>Autor: '.$row['news_author'].'</td>'."rn";
  49. echo ' </tr>'."rn";
  50. echo ' <tr>'."rn";
  51. echo '  <td>'.$row['news_text'].'</td>'."rn";
  52. echo ' </tr>'."rn";
  53. echo '</table><br />'."rn";
  54. }
  55. mysql_free_result ($result);
  56. }
  57. ?>
  58. <br />
  59. <br />
  60. <br />
  61. <br />
  62. <form action="ee.php" method="post">
  63. Topic:<br />
  64. <input type="text" style="width:200px" size="30" maxleght="100" name="news_topic" /><br />
  65. Topic opis:<br />
  66. <input type="text" style="width:200px" size="30" maxleght="100" name="news_topic_mini" /><br />
  67. Nick:<br />
  68. <input type="text" style="width:200px" size="30" maxleght="100" name="news_author" /><br />
  69. Text:<br />
  70. <textarea class="post" name="news_text" maxlength="255" cols="50" rows="10">Text.......</textarea><br />
  71. <input type="submit" name="submit" value="Wyslij" />
  72. </form>

Wszystko , pięknie chodzi . Lecz mam pytanie. Jak zrobić aby po wpisaniu index.php?id=(na przykład 1)
wyskakiwała news którego id jest 1 ?
Proszę o pomoc (IMG:http://forum.php.pl/style_emoticons/default/smile.gif) .

Ten post edytował Mazur_pl 11.05.2007, 19:07:22
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: 2.10.2025 - 04:07