Current location: Hot Scripts Forums » Programming Languages » PHP » index.php?page=news


index.php?page=news

Reply
  #1 (permalink)  
Old 09-27-03, 04:40 PM
perleo perleo is offline
Coding Addict
 
Join Date: Jul 2003
Location: Ireland
Posts: 269
Thanks: 0
Thanked 0 Times in 0 Posts
index.php?page=news

Okay, how do i do this without a database
on the index.php page is it possible to make arrays or something which include the code for that part part of the page and then print from that array.

Heres an example but it doesnt work ( duh! )

<?php

index.php?page=$blablabla

$main = {

<td> <h1> Welcome to the Main Page </h1> </td>
};

$news = {

<h1> Welcome to the news page </h1>
};

$contact = {

<h1> Contact Us below </h1>
mailto: contact@us.com?Subject=Contact from website

};

?>

Get my drift, is this possible???
Reply With Quote
  #2 (permalink)  
Old 09-27-03, 05:54 PM
Chroder Chroder is offline
Newbie Coder
 
Join Date: Sep 2003
Location: Toronto, Ontario
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
You mean you want to put lines of HTML in a variable? Use a heredoc:

PHP Code:

$myvar <<< HTML

    lines and lines and lines<br />
    of <font color="red">HTML</font>
HTML; 
__________________
DevBox.net | DevBoxForums.com
Reply With Quote
  #3 (permalink)  
Old 09-27-03, 06:08 PM
Mud Mud is offline
Newbie Coder
 
Join Date: Sep 2003
Location: Southern California
Posts: 94
Thanks: 0
Thanked 0 Times in 0 Posts
No i think he or she want s to know how to make a page link to like index.phppage=hi or something like her topic title
__________________
http://websoftblog.com/ - Web Software Blog
http://www.seekpire.com/ Make money searching!
http://www.gamingwise.com/ flash games!
Reply With Quote
  #4 (permalink)  
Old 09-27-03, 06:33 PM
gamextremer2003 gamextremer2003 is offline
Newbie Coder
 
Join Date: Jul 2003
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
I am short on time (thus I cannot create you code), but look up these:

SWITCH, CASE, BREAK.
__________________
Gamex
Reply With Quote
  #5 (permalink)  
Old 09-27-03, 11:28 PM
Chroder Chroder is offline
Newbie Coder
 
Join Date: Sep 2003
Location: Toronto, Ontario
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Mabe this thread would be what your after: http://programmingtalk.com/showthread.php?t=2299
__________________
DevBox.net | DevBoxForums.com
Reply With Quote
  #6 (permalink)  
Old 09-28-03, 01:57 AM
lokito[style] lokito[style] is offline
New Member
 
Join Date: Sep 2003
Location: melbourne australia
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Arrow done

ok, i did one 4 ya

<? if (empty($page)){
print"this is wot is displayed if the page is home page say index.php with no other tag!, if you want to say leave a link to another page you can use
<a href='index.php?page=testone'>test one</a><br><a href='index.php?page=testtwo'>test two</a>";
} else if ($page= testone) {
print"this test is using the include function so it displays a page";
include "testpage.php";
} else if ($page == testtwo) {
print"testing testing 123<br>
this test consists of information already being inside the php before uploading";
} else {
print " error: mail webmaster at blah@blahblah.com" ;
?>

there you go. hope it works 4 ya.
lokito[style]
Reply With Quote
  #7 (permalink)  
Old 09-28-03, 08:51 PM
the|Skrilla the|Skrilla is offline
Newbie Coder
 
Join Date: Jun 2003
Location: Louisiana, USA
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
The above code is faulty because the strings in the if...else statements are seen by the script as constants. Here is the best way to do it:

<?php
switch ($page)
{
case "a":
echo "contents of index.php?page=a";
break;

case "b":
echo "contents of index.php?page=b";
break;

default:
echo "contents of index.php";
}
?>
__________________
Lead Level Designer - Liquid Element

Last edited by the|Skrilla; 09-28-03 at 09:03 PM.
Reply With Quote
  #8 (permalink)  
Old 09-29-03, 06:29 AM
eddyvlad eddyvlad is offline
Wannabe Coder
 
Join Date: Sep 2003
Location: In The Bloody Pits Of Hell
Posts: 160
Thanks: 2
Thanked 0 Times in 0 Posts
Personally, i prefer the inlcude() function.

PHP Code:

<?

if (page == "news"){
         
$inc "news.php";
}
elseif (
page == "profile"){
         
$inc "profile.php";
}
else {
         
$inc "error.php";
}

include(
$inc);
?>

<a href="?page=news>News</a>
<a href="?page=profile>Profile</a>
That way, it's more expandable. Just make different file for different page. You might want to make seperate header too. If you squeeze all the pages in 1 page, it's going to be very big and consume processing time. Really it's expandable. One day you might want to be able to change bg color... e.g index.php?page=news&bgcolor=red&text=big
Reply With Quote
  #9 (permalink)  
Old 09-29-03, 02:47 PM
perleo perleo is offline
Coding Addict
 
Join Date: Jul 2003
Location: Ireland
Posts: 269
Thanks: 0
Thanked 0 Times in 0 Posts
thanks guys
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump


All times are GMT -5. The time now is 06:22 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.