Jump to content

index.php page question


pouncer

Recommended Posts

I'm using dreamweaver to design my site.

I came across this site http://www.evo7ution.com/dentaltrust/

whatever link we click on, the link is like http://www.evo7ution.com/dentaltrust/index.php?page=11

all the pages are part of the index.php

how has this been done? i think this is more effecient than having loads of different pages

anyone got any ideas?
Link to comment
Share on other sites

Yes it's done using $_GET

Each navigation link would have a particular url in such as <a href="index.php?page=aboutUs" />

Then in the code you would put

[code]

$page = $_GET['page'];

if($page == "aboutUs")
  {
    //echo the html for the aboutUs page here
  }
elseif($page == "contactUs")
  {
    //echo the html for the contactUs page here
  }

[/code]

Does that make sense?

If you wanted to split it up then you could just do each page as an included file, so put all of the html for the aboutUs page in a aboutUs.inc.php and contact us in contactUs.inc.php and then do the following


[code]

$page = $_GET['page'];

if($page == "aboutUs")
  {
    includes("aboutUs.inc.php");
  }
elseif($page == "contactUs")
  {
    includes("contacUs.inc.php");
  }

[/code]

In which case you may have well just have made each page separately anyway.  :P
Link to comment
Share on other sites

Here is an example of how I am doing it.

[code]if ($pg != "doctor_visits" && $pg != "insulin_pump" && $pg != "messages" && $pg != "rest" && $pg != "rest_food" && $pg != "tbl_events" && $pg != "user_data" && $pg != "user_data_options" && $pg != "user_passwords" && $pg != "user_table"){$pg = "main";}

if ($pg == ""){
$pg = "main";
}
$page=$pg.".php";
include($page) ;[/code]

Now that I look at it I can probably dump the if ($pg == ""){$pg = "main";}, it was there before I added the string of $pg !='s due to someone here being nice enough to show me how easy it is to insert their own code.

-John
Link to comment
Share on other sites

yeah mate, that makes more sense to me. thanks alot for clearing that up.

but in your first example:

[code]
$page = $_GET['page'];

if($page == "aboutUs")
  {
    //echo the html for the aboutUs page here
  }
elseif($page == "contactUs")
  {
    //echo the html for the contactUs page here
  }
[/code]

you say 'echo the html for the whatever page here

doesn't that mean i still need to have seperate pages on the webserver anyway?
Link to comment
Share on other sites

Here is my whole index.php page for you to look @

[code]<html>
<head>
<title>IOBE - PHP - MySQL </title>

<link rel='stylesheet' href='styles/style.css' type='text/css' media='all' />
</head>

<table style='width:100%; background-color:#E4E0E0' cellspacing='3' class='topborder'><tr><td style='text-align:left; vertical-align:bottom'>



</td>
    <td style='text-align:right'>&nbsp;</td>
</tr></table><table style='width:100%;' cellspacing='3' id='header'><tr><td style='text-align:left; vertical-align: middle;'>
<h2>
<div align="center"><img src='images/logo.png' alt='' /></div></td>
    <td style='text-align:left; vertical-align: middle;'><h2 align="left">&nbsp;&nbsp;&nbsp;IOBE</h2></td>
    <td style='text-align:right'><h2>PHP/MySql code writer &nbsp;&nbsp;&nbsp;</h2>
</td>
</tr></table>

<table style='width:100%' cellspacing='3'><td style='width:20%;'></td>
  <td style='width:60%;'><img src='images/blank.gif' width='1' height='1' alt='' /></td>
  <td style='width:20%;'></td></tr><tr><td height="379" style='width:20%; vertical-align: top;'>
<div class='spacer'>
<table cellpadding='0' cellspacing='0'>
<tr>
<td class='captiontopleft'><img src='images/blank.gif' width='24' height='3' alt='' style='display: block;' /></td>
<td class='captiontopmiddle'><img src='images/blank.gif' width='1' height='3' alt='' style='display: block;' /></td>
<td class='captiontopright'><img src='images/blank.gif' width='11' height='3' alt='' style='display: block;' /></td>
</tr>
</table>
<table cellpadding='0' cellspacing='0'>
<tr>
<td class='captionleft'><img src='images/blank.gif' width='24' height='18' alt='' style='display: block;' /></td>
<td class='captionbar' style='white-space:nowrap'>Main Menu</td>
<td class='captionend'><img src='images/blank.gif' width='12' height='18' alt='' style='display: block;' /></td>
<td class='captionmain'><img src='images/blank.gif' width='1' height='18' alt='' style='display: block;' /></td>
<td class='captionright'><img src='images/blank.gif' width='11' height='18' alt='' style='display: block;' /></td>
</tr>
</table>
<table cellpadding='0' cellspacing='0'>
<tr>
<td class='bodyleft'><img src='images/blank.gif' width='3' height='1' alt='' style='display: block;' /></td>
<td class='bodymain'>
 
<span><img src='images/bullet2.gif' alt='bullet' /><a href='index.php?pg=main'>Welcome</a></span><br/>
<span><img src='images/bullet2.gif' alt='bullet' /><a href='index.php?pg=faq'>FAQ</a></span><br/>
<!--span><img src='images/bullet2.gif' alt='bullet' /><a href='index.php?pg=messageboard'>Guest Book </a></span><br/-->
<span><img src='images/bullet2.gif' alt='bullet' /><a href='index.php?pg=downloads'>Downloads</a></span><br/>
<span><img src='images/bullet2.gif' alt='bullet' /><a href='index.php?pg=install'>Installation</a></span><br/>
<span><img src='images/bullet2.gif' alt='bullet' /><a href='index.php?pg=sample'>Sample Written Code</a></span><br/>
<span><img src='images/bullet2.gif' alt='bullet' /><a href='index.php?pg=plans'>Plans for IOBE</a></span><br/>
<span><img src='images/bullet2.gif' alt='bullet' /><a href='index.php?pg=gpl'>GNU General Public License </a></span><br/>

<span><img src='images/bullet2.gif' alt='bullet' /><a href='mailto:jsladek@iobe.net?subject=IOBE Application/Script Builder'>Contact Me</a></span><br/>

<span><img src='images/bullet2.gif' alt='bullet' /><a href='index.php?pg=donate'>Donate</a></span><br/>
</td>
<td class='bodyright'><img src='images/blank.gif' width='3' height='1' alt='' style='display: block;' /></td>
</tr>
</table>
<table cellpadding='0' cellspacing='0'>
<tr>
<td class='bottomleft'><img src='images/blank.gif' width='10' height='9' alt='' style='display: block;' /></td>
<td class='bottommain'><img src='images/blank.gif' width='1' height='9' alt='' style='display: block;' /></td>
<td class='bottomright'><img src='images/blank.gif' width='10' height='9' alt='' style='display: block;' /></td>
</tr>
</table>
</div>

<div class='spacer'></div>

</td>
<td style='width:20%; vertical-align:top'><?
if ($pg != "main" && $pg != "faq" && $pg != "messageboard" && $pg != "downloads" && $pg != "install" && $pg != "sample" && $pg != "plans" && $pg != "gpl" && $pg != "donate"){$pg = "main";}

if ($pg == ""){
$pg = "main";
}
$page=$pg.".php";
include($page) ;
?></td>


  </tr><tr>
  <td colspan='3' style='text-align:center' class='smalltext'>This site was created with IOBE.<br /></td></tr></table>
<div style='text-align:center'><table style='width:100%'><tr><td style='width:30%; vertical-align:top'>&nbsp;</td><td style='width:40%; vertical-align:top'></td><td style='width:30%; vertical-align:top'>&nbsp;</td></tr></table></div>
</body></html>
[/code]

you can see it here live http://www.iobe.net/proj/index.php

here is an example of a page that I include into the index.php by itself http://www.iobe.net/proj/gpl.php

and here it is included http://www.iobe.net/proj/index.php?pg=gpl

I'm not sure if this is the best way but it seems to work for me.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.