Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [MySQL][PHP] zmiana id w adresie na tytul - nie dziala
Michał90
post
Post #1





Grupa: Zarejestrowani
Postów: 267
Pomógł: 0
Dołączył: 16.05.2007

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


Witam,

  1. $query = mysql_query("select * from `games` where category = '" . clean($_GET['id']) . "'$limit ");
  2. while($row = mysql_fetch_array($query)) {
  3.  
  4. echo '<a href="' . $siteurl . 'games/' . $row['id'] . '/">' . $row['title'] . '</a>';
  5. }


Aktualnie gdy kliknę w utworzony link to wygląda on tak: http://adres.pl/games/342/ i działa OK
Jak zrobić, żeby link wyglądał tak:

http://adres.pl/games/NAZWAGRY/

Gdy zrobie tak:

  1. $query = mysql_query("select * from `games` where category = '" . clean($_GET['id']) . "'$limit ");
  2. while($row = mysql_fetch_array($query)) {
  3.  
  4. echo '<a href="' . $siteurl . 'games/' . $row['title'] . '/">' . $row['title'] . '</a>';
  5. }


To link wygląda tak jak chce czyli:
http://adres.pl/games/NAZWAGRY/

Ale niestety ten link nie działa...

Co zrobić, żeby działało to poprawnie?

Pozdrawiam



Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
Michał90
post
Post #2





Grupa: Zarejestrowani
Postów: 267
Pomógł: 0
Dołączył: 16.05.2007

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


próbowałem ale coś mi to nie działa, daje poprawny kod jak to zmienić?

  1. $query = mysql_query("select name from `categories` where id = '" . clean($_GET['id']) . "'") or die(mysql_error());
  2.  
  3. if(!isset($_GET['id'])) {
  4. header("Location: $siteurl");
  5. } elseif(empty($_GET['id'])) {
  6. header("Location: $siteurl");
  7. } elseif(mysql_num_rows($query) == 0) {
  8. header("Location: $siteurl");
  9. } else {
  10. $id = clean($_GET['id']);
  11. }
  12.  
  13. if (isset($_GET['page'])) {
  14. $pageno = clean($_GET['page']);
  15. } else {
  16. $pageno = 1;
  17. } // if
  18. $result = mysql_query("SELECT count(id) FROM `games` WHERE category = '$id'") or trigger_error("SQL", E_USER_ERROR);
  19. $query_data = mysql_fetch_row($result);
  20. $numrows = $query_data[0];
  21. $rows_per_page = $setting['pagination'];
  22. $lastpage = ceil($numrows/$rows_per_page);
  23. $pageno = (int)$pageno;
  24. if ($pageno < 1) {
  25. $pageno = 1;
  26. } elseif ($pageno > $lastpage) {
  27. $pageno = $lastpage;
  28. } // if
  29. $limit = 'LIMIT ' .($pageno - 1) * $rows_per_page .',' .$rows_per_page;
  30.  
  31. ?>


i kod, który wyświetla
  1. <?php
  2. $query = mysql_query("select * from `games` where category = '" . clean($_GET['id']) . "'$limit ");
  3. while($row = mysql_fetch_array($query)) {
  4.  
  5. echo '.....
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: 13.10.2025 - 09:10