Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [PHP][OOP] jak zrobic wyswietlanie show?id= ?
rafal5225
post 1.03.2011, 18:53:34
Post #1





Grupa: Zarejestrowani
Postów: 5
Pomógł: 0
Dołączył: 1.03.2011

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


witam smile.gif
ucze sie programowac w OOP, rozdzielilem juz sobie projekt na model, widok i kontroler.
no i mam dwa pliki: index.php ktory wyswietla z bazy tytuly i show.php, ktore wyswietla opis. no i jak sie teraz zabrac za to, zeby stworzyc cos w stylu
/show?id=2 a nie /show.php?id=2 ?

pozdrawiam
Go to the top of the page
+Quote Post
mat-bi
post 1.03.2011, 18:56:05
Post #2





Grupa: Zarejestrowani
Postów: 690
Pomógł: 92
Dołączył: 6.02.2011

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


mod_rewrite?
Go to the top of the page
+Quote Post
rafal5225
post 1.03.2011, 20:50:18
Post #3





Grupa: Zarejestrowani
Postów: 5
Pomógł: 0
Dołączył: 1.03.2011

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


no dzieki, ale nie do konca to kapuje.

samo htaccess chyba poprawnie wlaczylem, bo cos tam lapie i czasem sie blokuje, wiec dziala, ale jak zrobic jak mam cos takiego:

  1. <?php foreach ($posts as $post): ?>
  2. <li>
  3. <a href="/show?id=<?php echo $post['id'] ?>">
  4. <?php echo $post['title'] ?>
  5. </a>
  6. </li>
  7. <?php endforeach; ?>


tak chce miec w pliku index.php, no i co teraz mam wpisac w tym .htaccess ?

mam pliki
index.php
i
show.php

nie wiem kompletnie jak sie za to zabrac...
probowalem tak:
Kod
RewriteRule ^show?id=([^-]+)$ /show.php?id=$1

ale to mi cos nie dziala.

krotko mowiac jak zamiast wyswietlania
localhost/show.php?id=2
zrobic localhost/show?id=2 ?

pozdrawiam
Go to the top of the page
+Quote Post
modern-web
post 1.03.2011, 21:03:03
Post #4





Grupa: Zarejestrowani
Postów: 763
Pomógł: 117
Dołączył: 15.03.2010
Skąd: void

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


Proszę: http://corz.org/serv/tricks/htaccess2.php
Przypuszczam, że Ci się przyda wink.gif
Jeśli i tego nie zrozumiesz to pisz; wtedy wytłumaczę smile.gif
Pozdrawiam!


--------------------
Pomogłem? Kliknij `Pomógł`. To nic nie kosztuje, a mnie usatysfakcjonuje! ;)
Go to the top of the page
+Quote Post
rafal5225
post 1.03.2011, 21:34:37
Post #5





Grupa: Zarejestrowani
Postów: 5
Pomógł: 0
Dołączył: 1.03.2011

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


dzieki juz mniej wiecej kapuje, ale dalej mam problem.

zrobilem tak:

Kod
RewriteRule ^show /show.php


i teraz mi wywala blad

Internal Server Error

Cytat
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, admin@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.


prosilbym o rozwiazanie smile.gif
Go to the top of the page
+Quote Post
mat-bi
post 1.03.2011, 21:39:49
Post #6





Grupa: Zarejestrowani
Postów: 690
Pomógł: 92
Dołączył: 6.02.2011

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


Nie zakończyłeś

RewriteRule ^show$ /show.php [L]
Go to the top of the page
+Quote Post
modern-web
post 1.03.2011, 21:44:03
Post #7





Grupa: Zarejestrowani
Postów: 763
Pomógł: 117
Dołączył: 15.03.2010
Skąd: void

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


1. Plik zapisujesz w UTF-8, a serwer może interpretować tylko ANSI;
2. Masz wyłączoną opcję mod_rewrite w konfiguracji serwera Apache.
3. Kolega wyżej stwierdził fakt... wink.gif

Ten post edytował modern-web 1.03.2011, 21:46:04


--------------------
Pomogłem? Kliknij `Pomógł`. To nic nie kosztuje, a mnie usatysfakcjonuje! ;)
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: 4.07.2025 - 22:53