?p=blah thingy

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

qads
DevNet Resident
Posts: 1199
Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane

Post by qads »

you dont need to use echo on each line, here is a example;

Code: Select all

<?php
$page1 = '<html>
<head>
<title>page1</title>
<script>
alert(''Hello'');
</script>
</head>
<body>
Top of the world ma!
</body>
</html>';

$page2 = '<html>
<head>
<title>page2</title>
<script>
alert(''Hello'');
</script>
</head>
<body>
Top of the world ma!
</body>
</html>';
if($p == 2)
{
echo $page2;
}
else
{
echo $page1;
}
?>
simple as that. just make sure you search and replace ' with '', you can do that useing notepad!

i bet nay is gona come around and talk about heredoc :lol:
C
Forum Newbie
Posts: 14
Joined: Wed Dec 10, 2003 1:31 am

Post by C »

qads wrote:you dont need to use echo on each line, here is a example;

Code: Select all

<?php
$page1 = '<html>
<head>
<title>page1</title>
<script>
alert(''Hello'');
</script>
</head>
<body>
Top of the world ma!
</body>
</html>';

$page2 = '<html>
<head>
<title>page2</title>
<script>
alert(''Hello'');
</script>
</head>
<body>
Top of the world ma!
</body>
</html>';
if($p == 2)
{
echo $page2;
}
else
{
echo $page1;
}
?>
simple as that. just make sure you search and replace ' with '', you can do that useing notepad!

i bet nay is gona come around and talk about heredoc :lol:
accually on my phpnuke site, http://project-epsilon.com i have a module that converts normal html to phpnuke module format..and it adds echo and all the slashes for me :)...btw, whats heredoc?
Nay
Forum Regular
Posts: 951
Joined: Fri Jun 20, 2003 11:03 am
Location: Brisbane, Australia

Post by Nay »

C wrote: now that i'll be using the "echo" tag to put in the html to the php file will i have to add the "echo" tag to each line of html that i export from photoshop? or is there an programm that will do it for me?
You have come to the right place my friend 8). *recruits you*. You use heredoc for it.

Code: Select all

$html = <<< HTML
<html>

<head>

bla bla bla

Yeah, syntax is bad, isn't it?
HTML;
But for loads of HTML, it's more...........sensible to have them in an external file and use require(). So you seperate the HTML and the PHP. Much neater.

And the images, there's really not a way. You can just go to View -> Source, or press CTRL + U in Mozilla and view the source, and get the images from there.

-Nay
C
Forum Newbie
Posts: 14
Joined: Wed Dec 10, 2003 1:31 am

Post by C »

ok, one more question..lol: if u go http://www.venox.org/?p=home&style=default there u can see that in ur browser's url box it will display the ?p=home thing that we have been talking about but it also has a &style=default. on the home page of that site it has a set of links allowing u to cahnge the colors of the page, clicking on one of them also changes that &style= default tag to &style=blue (if u click on the blue). how is that done?
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

Cookies, or Sessions most likely.

btw: thanks for the link, that site (and his affiliates) are mega eye-candy. :o :D

This has to be the coolest layout i've ever seen: http://www.shiver7.com/

btw he/she/they even got a tutorial on this topic: http://www.shiver7.com/tutorials/97/

heh :wink:
AnsonM
Forum Commoner
Posts: 72
Joined: Thu Sep 25, 2003 7:21 am

Post by AnsonM »

there is another way... if u want to know, send me a PM.. :)
TheDeath2k4
Forum Newbie
Posts: 5
Joined: Wed Dec 10, 2003 8:07 pm
Location: somewhere....nowhere.....
Contact:

Post by TheDeath2k4 »

C wrote:ok, one more question..lol: if u go http://www.venox.org/?p=home&style=default there u can see that in ur browser's url box it will display the ?p=home thing that we have been talking about but it also has a &style=default. on the home page of that site it has a set of links allowing u to cahnge the colors of the page, clicking on one of them also changes that &style= default tag to &style=blue (if u click on the blue). how is that done?
ok this is how i did it:

Code: Select all

//INDEX.PHP
<?php
include("menu.php");
?page=$_GET&#1111;'page']
$indexcontent = "blah";
$page1content = "blah1";
$page2content = "blah2";
if ($page ==  page1)
&#123;
      print("page1content");
&#125;
elseif ($page == page2)
&#123;
       print("page2content");
&#125;
else
&#123;
       print("indexcontent");
&#125;
//END INDEX.PHP
?>

<?php
//MENU.PHP, note i took this directly from my page i coded with it, you can view at //http://uberhost.ath.cx/thedeath2k4 change this code as nessicary. This also includes a //simple text design switcher.

<?php

$design = $_GET&#1111;'design'];
if ($design == "aqua")
&#123;
$menu = '

<center>
<a href="index.php?page=&design=aqua">Home</a><br>
<a href="index.php?page=sigsavas&design=aqua">Sigs and Avatars</a><br>
<a href="index.php?page=designs&design=aqua">Designs</a><br>

<br /></center>';
echo $menu;
echo "Design: $design<br />";
$change = '<a href="index.php?page=sigsavas&design=pixel">Pixel</a>';
echo $change;
&#125;
else
&#123;
$menu = '
<center>
<a href="index.php?page=&design=pixel">Home</a><br>
<a href="index.php?page=sigsavas&design=pixel">Sigs and Avatars</a><br>
<a href="index.php?page=designs&design=pixel">Designs</a><br>
<br /></center>';
echo $menu;
echo "<center>Design: pixel<br />";
$change = '<a href="index.php?page=sigsavas&design=aqua">Aqua</a></center>';
echo $change;
&#125;
?>
//END MENU.PHP
hope that helps :) oh and you can use echo for anything, ii was just feeling like using print when i made it.
Last edited by TheDeath2k4 on Thu Dec 11, 2003 8:26 pm, edited 1 time in total.
C
Forum Newbie
Posts: 14
Joined: Wed Dec 10, 2003 1:31 am

Post by C »

Sami wrote:Cookies, or Sessions most likely.

btw: thanks for the link, that site (and his affiliates) are mega eye-candy. :o :D

This has to be the coolest layout i've ever seen: http://www.shiver7.com/

btw he/she/they even got a tutorial on this topic: http://www.shiver7.com/tutorials/97/

heh :wink:
hahaha...lols...damn, there is a tutorial for everything...
TheDeath2k4
Forum Newbie
Posts: 5
Joined: Wed Dec 10, 2003 8:07 pm
Location: somewhere....nowhere.....
Contact:

Post by TheDeath2k4 »

they do don't they? i didn't notice the tutorial there.
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

I just wanted to show how I do my template system as I described earlier.

Code: Select all

<?php
if (isset($_GET['p']))
{
    $p = $_GET['p'];
}
switch ($p)
{
    default:
      require_once "inc/home.inc.php";
    break;
    case 'home':
      require_once "inc/home.inc.php"; // no html headers or footers, just code
    break;
    // etc...
}		  
?>
C
Forum Newbie
Posts: 14
Joined: Wed Dec 10, 2003 1:31 am

Post by C »

hmmm...it appears there are many different ways...im using quads' version cuz thats what i saw 1st...lol
Nay
Forum Regular
Posts: 951
Joined: Fri Jun 20, 2003 11:03 am
Location: Brisbane, Australia

Post by Nay »

Sami wrote:Cookies, or Sessions most likely.

btw: thanks for the link, that site (and his affiliates) are mega eye-candy. :o :D

This has to be the coolest layout i've ever seen: http://www.shiver7.com/

btw he/she/they even got a tutorial on this topic: http://www.shiver7.com/tutorials/97/

heh :wink:
Yeah! Finally I remember, I went to that site a while ago while on a hunt for 3D tutorials. I lost the URL <_<.

la la la la

-Nay
C
Forum Newbie
Posts: 14
Joined: Wed Dec 10, 2003 1:31 am

Post by C »

thanks all! its all working execpt for the fact that sometimes it will not load any of the images. even if u refresh. u have to close ur browser completly and open it agian in order to see the images. why is that and how can i fix it?
Post Reply