Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Zmienna URL
wert1
post 22.03.2007, 17:50:59
Post #1





Grupa: Zarejestrowani
Postów: 175
Pomógł: 2
Dołączył: 22.03.2007
Skąd: localhost

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


Adres strony to mojastrona.pl/index.php?show=2

Kod
<? if(!isset($show)) {
include"strony/newsy.php"; }
else if ($show=='1') {
include"strony/newsy.php"; }
else if($show=='2') {
include"strony/linki.php"; }
else if($show=='3') {
include"strony/onas.php"; }
else if($show=='4') {
include"strony/buttony.php"; }
else if($show=='5') {
include"strony/kontakt.php"; }
else {
echo("Nie ma takiej strony"); } ?>


a jak zrobić żeby był taki adres questionmark.gifquestionmark.gif?

mojastrona.pl/index.php?show=2&id=1


--------------------
"Homo sum, humani nihil a me alienum puto."
"Necessitas ultimum et maximum telum est."
"Ventem seminabunt et turbinem metent."
"Gallia est omnis divisa in partes tres..."
Go to the top of the page
+Quote Post
Mary$
post 22.03.2007, 17:56:22
Post #2





Grupa: Zarejestrowani
Postów: 113
Pomógł: 1
Dołączył: 19.02.2007
Skąd: 3city

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


Cytat
a jak zrobić żeby był taki adres questionmark.gifquestionmark.gif?

mojastrona.pl/index.php?show=2&id=1

wpisać go. a jeżeli chcesz rozpoznawać za pomocą show oraz id co chcesz wczytać to masz cos takiego

  1. <?php
  2. if (($_GET['show'] == "news")&&($_GET['id'] == "2"))
  3. include('news.php');
  4. elseif(($_GET['show'] == 'news')&&($_GET['id'] == "1"))
  5. include('news2.php');
  6. ?>


jeżeli o to ci chodziło...


--------------------
Nie ma rzeczy niemożliwych - są tylko czasochłonne i mało opłacalne.
Go to the top of the page
+Quote Post
wert1
post 22.03.2007, 18:00:35
Post #3





Grupa: Zarejestrowani
Postów: 175
Pomógł: 2
Dołączył: 22.03.2007
Skąd: localhost

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


Tak , super ale czy nie ma innego sposobu questionmark.gifquestionmark.gif


--------------------
"Homo sum, humani nihil a me alienum puto."
"Necessitas ultimum et maximum telum est."
"Ventem seminabunt et turbinem metent."
"Gallia est omnis divisa in partes tres..."
Go to the top of the page
+Quote Post
Mary$
post 22.03.2007, 18:04:29
Post #4





Grupa: Zarejestrowani
Postów: 113
Pomógł: 1
Dołączył: 19.02.2007
Skąd: 3city

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


możesz uzyć switch" title="Zobacz w manualu PHP" target="_manual


--------------------
Nie ma rzeczy niemożliwych - są tylko czasochłonne i mało opłacalne.
Go to the top of the page
+Quote Post
Balas
post 22.03.2007, 18:09:56
Post #5





Grupa: Zarejestrowani
Postów: 347
Pomógł: 0
Dołączył: 27.08.2005
Skąd: Inowrocław

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


Zalezy co chcesz osiagnac winksmiley.jpg

najlatwiej w
Cytat
strony/newsy.php

pobierasz id z geta i robisz z nim co chcesz, np. wybierasz odpowiedni rekord z bazy lub includujesz odpowiedni plik, np.
  1. <?php
  2. $id= $_GET['id'];
  3. include('./strony/newsy/news_'.$id.'.php'); //include strony news_1.php, news_2.php itd.
  4. ?>

oczywisice pomijajac kwestie bezpieczenstwa

Ten post edytował Balas 22.03.2007, 18:10:22


--------------------
Go to the top of the page
+Quote Post
wert1
post 22.03.2007, 19:44:09
Post #6





Grupa: Zarejestrowani
Postów: 175
Pomógł: 2
Dołączył: 22.03.2007
Skąd: localhost

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


Chodzi mi oto żeby w pliku index.php było to:
  1. <? if(!isset($show)) {
  2. include"strony/newsy.php"; }
  3. else if ($show=='1') {
  4. include"strony/newsy.php"; }
  5. else if($show=='2') {
  6. include"strony/linki.php"; }
  7. else if($show=='3') {
  8. include"strony/onas.php"; }
  9. else if($show=='4') {
  10. include"strony/buttony.php"; }
  11. else if($show=='5') {
  12. include"strony/kontakt.php"; }
  13. else {
  14. echo("Nie ma takiej strony"); } ?>

a plik news miał własnie to z ID


--------------------
"Homo sum, humani nihil a me alienum puto."
"Necessitas ultimum et maximum telum est."
"Ventem seminabunt et turbinem metent."
"Gallia est omnis divisa in partes tres..."
Go to the top of the page
+Quote Post
Mary$
post 22.03.2007, 19:49:50
Post #7





Grupa: Zarejestrowani
Postów: 113
Pomógł: 1
Dołączył: 19.02.2007
Skąd: 3city

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


a plik news opiera sie o baze danych, czy o co? jeżeli chcesz to w pliku news robisz co chcesz z tym id, uzywając $_GET['id']. nie bardzo wiem o co Ci chodzi... blinksmiley.gif

Ten post edytował Mary$ 22.03.2007, 19:50:30


--------------------
Nie ma rzeczy niemożliwych - są tylko czasochłonne i mało opłacalne.
Go to the top of the page
+Quote Post
em1X
post 22.03.2007, 19:50:51
Post #8





Grupa: Zarejestrowani
Postów: 984
Pomógł: 41
Dołączył: 16.03.2002
Skąd: Płock

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


Moze Ty wiesz co masz na mysli, ale to nie oznacza, ze inni to rozumieją. Powiedz co chcesz osiagnac, tylko błagam, po polsku.


--------------------
eh, co polska wódka to polska wódka
Go to the top of the page
+Quote Post
bne
post 22.03.2007, 21:30:53
Post #9





Grupa: Zarejestrowani
Postów: 83
Pomógł: 1
Dołączył: 18.10.2006

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


Nic nie musisz zmieniać w indexie, adres wpisujesz z ID a potem w news.php korzystasz z $_GET['id']


--------------------
Darmowa wyszukiwarka MP3
Go to the top of the page
+Quote Post
wert1
post 23.03.2007, 06:41:30
Post #10





Grupa: Zarejestrowani
Postów: 175
Pomógł: 2
Dołączył: 22.03.2007
Skąd: localhost

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


Chce osiągnąć takiego typu URL mojastrona.pl/index.php?show=2&id=1

ale żeby w index.php
  1. <? if(!isset($show)) {
  2. include"strony/newsy.php"; }
  3. else if ($show=='1') {
  4. include"strony/newsy.php"; }
  5. else if($show=='2') {
  6. include"strony/linki.php"; }
  7. else if($show=='3') {
  8. include"strony/onas.php"; }
  9. else if($show=='4') {
  10. include"strony/buttony.php"; }
  11. else if($show=='5') {
  12. include"strony/kontakt.php"; }
  13. else {
  14. echo("Nie ma takiej strony"); } ?>



i właśnie nie wiem co zrobić w pliku newsy


--------------------
"Homo sum, humani nihil a me alienum puto."
"Necessitas ultimum et maximum telum est."
"Ventem seminabunt et turbinem metent."
"Gallia est omnis divisa in partes tres..."
Go to the top of the page
+Quote Post
Kicok
post 23.03.2007, 07:27:44
Post #11





Grupa: Zarejestrowani
Postów: 1 033
Pomógł: 125
Dołączył: 17.09.2005
Skąd: Żywiec

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


W pliku newsy.php zrób:
  1. <?php
  2. if(isset($_GET['id'])) {
  3. $id = intval($_GET['id']);
  4. }
  5. else {
  6. // Nie podano numeru newsa. Wyświetl użytkownikowi informację, wyświetl ostatnio d
    odany news, albo listę wszystkich newsów - to już zależy od tego jak sobie swój system newsów wyobrażasz
  7. }
  8. ?>


--------------------
"Sumienie mam czyste, bo nieużywane."
Go to the top of the page
+Quote Post
wert1
post 23.03.2007, 10:26:52
Post #12





Grupa: Zarejestrowani
Postów: 175
Pomógł: 2
Dołączył: 22.03.2007
Skąd: localhost

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


A gdzie mam to wcisnąć questionmark.gif?

  1. <?php
  2. include"strony/newsy.php"
  3. ?>


--------------------
"Homo sum, humani nihil a me alienum puto."
"Necessitas ultimum et maximum telum est."
"Ventem seminabunt et turbinem metent."
"Gallia est omnis divisa in partes tres..."
Go to the top of the page
+Quote Post
Łukasz O.
post 23.03.2007, 10:41:38
Post #13





Grupa: Zarejestrowani
Postów: 191
Pomógł: 5
Dołączył: 13.01.2007

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


w index.php? albo nie - najlepiej w koszu koło biurka - a najlepiej jak sąsiadowi pod wycieraczkę wrzucisz

przecież już to masz w index'ie, więc o co Ci biega? bo nie rozumiem za bardzo


--------------------
"Don't tell me you want a bridge - show me the canyon you want to cross" Giuseppe Delena
Go to the top of the page
+Quote Post
misiek172
post 23.03.2007, 13:26:14
Post #14





Grupa: Zarejestrowani
Postów: 656
Pomógł: 3
Dołączył: 26.10.2005
Skąd: Częstochowa

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


nie zabardzo rozumiem w czym tkwi problem...

cały czas mówisz że chcesz aby to wyglądało tak:

mojastrona.pl/index.php?show=2&id=1

no to piszesz:

<a href="mojastrona.pl/index.php?show=".$show."&id=".$id.">buttonik</a>

biggrin.gif


--------------------
zmoderowano - waga i rozmiar
Go to the top of the page
+Quote Post
wert1
post 23.03.2007, 15:59:44
Post #15





Grupa: Zarejestrowani
Postów: 175
Pomógł: 2
Dołączył: 22.03.2007
Skąd: localhost

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


Ale gdzie mam wcisnąć w ten kod
  1. <?php
  2. if(isset($_GET['id'])) {
  3. $id = intval($_GET['id']);
  4. }
  5. else {
  6. // Nie podano numeru newsa. Wyświetl użytkownikowi informację, wyświetl ostatnio dodany news, albo listę wszystkich newsów - to już zależy od tego jak sobie swój system newsów wyobrażasz
  7. }
  8. ?>



To
Kod
include"strony/newsy.php"
?>


Ten post edytował wert1 23.03.2007, 16:00:38


--------------------
"Homo sum, humani nihil a me alienum puto."
"Necessitas ultimum et maximum telum est."
"Ventem seminabunt et turbinem metent."
"Gallia est omnis divisa in partes tres..."
Go to the top of the page
+Quote Post
bronchos
post 23.03.2007, 16:10:34
Post #16





Grupa: Zarejestrowani
Postów: 25
Pomógł: 0
Dołączył: 16.03.2007

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


Człowieku, zastanów się trochę na problemem, potem pisz...

index.php:
  1. <?php
  2. $show = isset($_GET['show']) ? $_GET['show'] : 0;
  3. switch ($show) {
  4.  case '1':
  5. include "strony/newsy.php";
  6. break;
  7.  case '2':
  8. include "strony/costam.php";
  9. break;
  10.  case '3':
  11. include "strony/costam_jeszcze.php";
  12. break;
  13.  default:
  14. include "strony/newsy.php";
  15. break;
  16. }
  17. ?>


newsy.php:
  1. <?php
  2. if(isset($_GET['id'])) {
  3. $id = intval($_GET['id']);
  4. } else {
  5.  // Nie podano numeru newsa. Wyświetl użytkownikowi informację, 
  6.  // wyświetl ostatnio dodany news, albo listę wszystkich newsów -
  7.  // to już zależy od tego jak sobie swój system newsów wyobrażasz
  8. }
  9. ?>


Tak trudno pomyśleć?

Ten post edytował bronchos 23.03.2007, 16:14:57
Go to the top of the page
+Quote Post
wert1
post 25.03.2007, 08:07:30
Post #17





Grupa: Zarejestrowani
Postów: 175
Pomógł: 2
Dołączył: 22.03.2007
Skąd: localhost

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



W pliku newsy powino być to :

  1. <?php
  2. if (($_GET['id'] == "1"))
  3. include ("strony/1.php");
  4. elseif(($_GET['id'] == "2"))
  5. include ("strony/2.php");
  6. elseif(($_GET['id'] == "3"))
  7. include ("strony/3.php");
  8. elseif(($_GET['id'] == "4"))
  9. include ("strony/4.php");
  10. elseif(($_GET['id'] == "5"))
  11. include ("strony/5.php");
  12. elseif(($_GET['id'] == "6"))
  13. include ("strony/6.php");
  14. elseif(($_GET['id'] == "7"))
  15. include ("strony/7.php");
  16. ?>


Bardzo dziękuję za pomoc

TO JEST NOW POST


w pliku news mam to
  1. <?php
  2. if (($_GET['id'] == "1"))
  3. include ("strony/1.php");
  4. elseif(($_GET['id'] == "2"))
  5. include ("strony/2.php");
  6. elseif(($_GET['id'] == "3"))
  7. include ("strony/3.php");
  8. elseif(($_GET['id'] == "4"))
  9. include ("strony/4.php");
  10. elseif(($_GET['id'] == "5"))
  11. include ("strony/5.php");
  12. elseif(($_GET['id'] == "6"))
  13. include ("strony/6.php");
  14. elseif(($_GET['id'] == "7"))
  15. include ("strony/7.php");
  16. ?>


i menu do sterowania adresami


mi chodzi o to żeby na stronie np. : mojastrona.pl/index.php?show=2&id=1

lub : mojastrona.pl/index.php?show=2&id=2 itp.

i wyświetla się to menu do sterowania adresami

a ja chcę żeby to menu wyświetlało się po wpisaniu : index.php?show=2

a po wpisaniu index.php?show=2&id=1 itp.

już to menu znika



-------------------------
taki duży rozmiar czcionki
nie jest chyba konieczny questionmark.gif
~Cienki1980


Ten post edytował Cienki1980 25.03.2007, 08:35:58


--------------------
"Homo sum, humani nihil a me alienum puto."
"Necessitas ultimum et maximum telum est."
"Ventem seminabunt et turbinem metent."
"Gallia est omnis divisa in partes tres..."
Go to the top of the page
+Quote Post
Mary$
post 25.03.2007, 15:55:54
Post #18





Grupa: Zarejestrowani
Postów: 113
Pomógł: 1
Dołączył: 19.02.2007
Skąd: 3city

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


ja sie już zamotałem w tym wszystkim, ale jeżeli dobrze do mnie dotarło, to chcesz coś takiego:
  1. <?php
  2. If (!IsSet($_GET['id'])){
  3. if (($_GET['id'] == "1")){
  4. //co sie dzieje, jeżeli $_GET['id'] nie jest zasetowane
  5. include ("strony/1.php");
  6. elseif(($_GET['id'] == "2"))
  7. include ("strony/2.php");
  8. elseif(($_GET['id'] == "3"))
  9. include ("strony/3.php");
  10. elseif(($_GET['id'] == "4"))
  11. include ("strony/4.php");
  12. elseif(($_GET['id'] == "5"))
  13. include ("strony/5.php");
  14. elseif(($_GET['id'] == "6"))
  15. include ("strony/6.php");
  16. elseif(($_GET['id'] == "7"))
  17. include ("strony/7.php");
  18. }else
  19. {
  20. //cos, co sie dzieje, gdy $_GET['id'] jest zasetowane
  21. }
  22. ?>

isset()" title="Zobacz w manualu PHP" target="_manual


--------------------
Nie ma rzeczy niemożliwych - są tylko czasochłonne i mało opłacalne.
Go to the top of the page
+Quote Post
misiek172
post 25.03.2007, 22:27:23
Post #19





Grupa: Zarejestrowani
Postów: 656
Pomógł: 3
Dołączył: 26.10.2005
Skąd: Częstochowa

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


dla czytelnosci polecam zamienic instrukcje warunkową IF na SWITCH smile.gif


--------------------
zmoderowano - waga i rozmiar
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: 14.08.2025 - 05:18