Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP][MySQL] Menu i podstrony
danielv13
post
Post #1





Grupa: Zarejestrowani
Postów: 48
Pomógł: 0
Dołączył: 4.12.2006

Ostrzeżenie: (10%)
X----


Witam. Mam w bazie tabelę podstrony (id, tutul, tresc...). Jak mam zrobić, aby w menu pojawiały sie linki (tytuł) a po kliknięciu tresc otwierała się w innej komórce tabeli??
Jak narazie kombinuje z czymś takim:

Menu:

  1. <? 
  2. mysql_connect ("$host", "$dbuser", "$dbpass") or die ("BLAD!<br> Nie mozna polaczyc sie z baza danych! Sprawdx czy wpisane przez Ciebie dane 
    sa poprawne!"
    );
  3. mysql_select_db ("$dbname") or die ("BLAD!<br> Nie mozna odnalezdx bazy danych o nazwie $dbname");
  4.  
  5. $query = "SELECT * FROM podstrony ORDER BY id";
  6. $result = mysql_query($query);
  7. while($r = mysql_fetch_array($result)) {
  8. $nr = $r['id'];
  9. $tytul = $r['tytul'];
  10. echo " - <a href="index.php?strona=$nr">$tytul</a><BR>";
  11. }
  12. ?>



i Treść:

  1. <?
  2. if ($strona){
  3. $query = "SELECT * FROM podstrony WHERE id=$nr";
  4. $result = mysql_query($query);
  5. echo " - $tytul</a><BR>";
  6. }
  7. ?>



Proszę o pomoc (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
danielv13
post
Post #2





Grupa: Zarejestrowani
Postów: 48
Pomógł: 0
Dołączył: 4.12.2006

Ostrzeżenie: (10%)
X----


O kurde działa (IMG:http://forum.php.pl/style_emoticons/default/biggrin.gif) Dzięki mistrzu Void!! (IMG:http://forum.php.pl/style_emoticons/default/tongue.gif)
Masz stałego klienta (IMG:http://forum.php.pl/style_emoticons/default/biggrin.gif)
Pokarzę Ci potem moje "dzieło" (IMG:http://forum.php.pl/style_emoticons/default/haha.gif) ...

Nie chcę nikogo krytykować, ale zobaczcie tutaj:

http://forum.webcity.pl/index.php?showtopic=4943

Napisałem go wczoraj o podobnej porze jak tu (IMG:http://forum.php.pl/style_emoticons/default/biggrin.gif) Jest powalająca różnica (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)

Teraz zrobiłem wg. instrukcji:

  1. <?php
  2. if ($_GET['polecenie']=='usun') {
  3.  
  4. echo'<br><b>Usuwanie</b><BR><br>';
  5. echo '<table width="420" bgcolor="#00CCFF">';
  6.  
  7. mysql_connect ("$host", "$dbuser", "$dbpass") or die ("BLAD!");
  8. mysql_select_db ("$dbname") or die ("BLAD!");
  9.  
  10. $query = "SELECT * FROM podstrony ORDER BY id";
  11. $result = mysql_query($query);
  12. while($r = mysql_fetch_array($result)) {
  13. $id = $r['id'];
  14. $tytul = $r['tytul'];
  15. echo "<tr><td width="250"><div align="center">$tytul</td><td width="170"><a href="podstrony.php?usun=$id">Usuń</a></td></tr>";
  16. }
  17. echo'</table><br><br>';
  18. }
  19.  
  20. if (isset($_GET['usun'])) {
  21.  
  22. mysql_connect ("$host", "$dbuser", "$dbpass") or die ("BLAD!<br> Nie mozna polaczyc sie z baza danych! Sprawdx czy wpisane przez Ciebie dane 
    sa poprawne!"
    );
  23. mysql_select_db ("$dbname") or die ("BLAD!<br> Nie mozna odnalezdx bazy danych o nazwie $dbname");
  24.  
  25. $query = "DELTE FROM podstrony WHERE id=".$_GET['usun']."";
  26. $result = mysql_query ($query);
  27. echo'Usunięto!';
  28. }
  29. ?>


i nie chce usuwać (IMG:http://forum.php.pl/style_emoticons/default/sad.gif) WHY?

Ten post edytował danielv13 12.06.2007, 18:02:07
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: 27.12.2025 - 04:39