Jump to content

[SOLVED] one php file


tml

Recommended Posts

HI, i where wondering how to make more pages in one like. index.php?page=1 or something like that...

if any can help me with the code i be more than happy. im new to php.

so i would like the code so i can just copy and paste, and i would like to know how my link should be etc. <a href index.php?page=1....

Link to comment
https://forums.phpfreaks.com/topic/126602-solved-one-php-file/
Share on other sites

HI, i where wondering how to make more pages in one like. index.php?page=1 or something like that...

 

Sorry I would like to help you but I don't understand exactly what you want or are trying to accomplish.  Could you give an example or be more specific?

Link to comment
https://forums.phpfreaks.com/topic/126602-solved-one-php-file/#findComment-654671
Share on other sites

i can try...

 

something like this:

 

i want to make my layout in index.php so my menu are there on all pages like

 

home href=index.php

news href=index.php?id1

something els href=index.php?id2

 

then i make the code so rest only be on the page i want

(index.php)

index

hej

index.php?id1

new

index.php?id2

something

 

and keep making new sites without change menu and layout.

 

i know i can do it with include page's but i just want one dokument

 

 

i know the code in asp if u know anything about that.

<%

 

id=Request.QueryString("id"): if id="" then id=0

 

Select case id

case 0 ' forside %>

page index

<% case 1 ' default.asp2?id=1 %>

page 1

<% case 2 ' default.asp2?id=2 %>

<% case 3 ' default.asp2?id=3 %>

<% case else ' alle andre %>

<% End Select %>

 

and link would be href=default.asp2?id=1  and so

Link to comment
https://forums.phpfreaks.com/topic/126602-solved-one-php-file/#findComment-654674
Share on other sites

You can grab the HTTP variables by using $_GET[''];.  You also need to have id=# like in you ASP example, not id2.  For example:

 

// For page index.php?id=1
if ($_GET['id'] == 1)
{
      //Display info for ID 1
}
if ($_GET['id'] == 1)
{
     //Display info for ID 2
}

 

You can also break it up into case statements like the one in your ASP code...  Does this help?  Let me know!

Link to comment
https://forums.phpfreaks.com/topic/126602-solved-one-php-file/#findComment-654676
Share on other sites

i did put the following in my php document i tryid open, then it just report with some text. like i said im new so i just need to copy and paste hehe, but are the not suppose to be a opening line like <?php or something? but thx for u helping

 

if ($_GET['id'] == 1)

{

<?php

echo "hej side 1";

?>      //Display info for ID 1

}

 

if ($_GET['id'] == 2)

{

<?php

echo "hej side 2";

?>    //Display info for ID 2

}

Link to comment
https://forums.phpfreaks.com/topic/126602-solved-one-php-file/#findComment-654686
Share on other sites

First, please use the code tags, make life easier for everyone.

 

Second, you're using the <?php and ?> tags in the wrong place...  All the code you posted is PHP, try this:

 

if ($_GET['id'] == 1)
{
echo "hej side 1";      //Display info for ID 1
}

if ($_GET['id'] == 2)
{
echo "hej side 2";     //Display info for ID 2
}
?>

Link to comment
https://forums.phpfreaks.com/topic/126602-solved-one-php-file/#findComment-654694
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.