Soldato
Hi all,
Have spent a couple of days attempting to learn some further PHP coding as my current learn of knowledge is some what lacking.
I know a little about case and switch, how to create an array, use includes and call content etc.....
Now i've got a site (just personal, hobby) which i'm running locally via a WAMP server which i'm having a few headaches with.
I'll explain the layout so you get the jist of where i need help.
index.php - of course the main page, simply consists of includes
header.php - the header of my document
footer.php - the footer
content.php - to be used to load varying content into an area of the page, i don't want to keep creating new pages and include the header/footer again and again.
Included in the header is a further include for a css tab menu (menu.php) that i'd like to have change dependant on the page loaded.
I have split the the active and non-active links of the header into arrays inside this file, like so...
With the menu i have a <li> element containing <a href> will be a normal tab, and those containing a <span> element are the current/active tab.
In the header is the following....
Aware the linsk mostly point nowhere yet... Want to make it work first...
Inside the content.php i have the following.... (early stage)
Can anyone explain how i can firstly have the content.php return content 'x' when no variable/case is present ($page or $blah), so basically when i'm on the index, $page and $blah will not be in the URL and as such i'd like something else displayed.
Secondly how do i then have the menu check to see if $page of $blah has been called.
As said, i know only little about php, and this is some of what i've been learning over the last few days.
I've found it hard to find a guide that isn't too basic or too advanced to help, though some have given me pointers, they don't really apply to what i'm wanting to do.
I'm wanting to create a site with PHP, HTML and CSS, no database for my personal projects and/or guides etc...
I can find info on using case/switch to change the content, but do not know how to check what the value or variable is to display different code into the menu.
I think i need something that simple says.....
If page is equal to index....
else if page is Projects (when the project case is equal to anything - index.php?project=1 <-- example)...
Sorry for the long winded post, trying to explain best i can....
If anyone has any pointers, links or suggestions they are all welcome, thanks...
Have spent a couple of days attempting to learn some further PHP coding as my current learn of knowledge is some what lacking.
I know a little about case and switch, how to create an array, use includes and call content etc.....
Now i've got a site (just personal, hobby) which i'm running locally via a WAMP server which i'm having a few headaches with.
I'll explain the layout so you get the jist of where i need help.
index.php - of course the main page, simply consists of includes
header.php - the header of my document
footer.php - the footer
content.php - to be used to load varying content into an area of the page, i don't want to keep creating new pages and include the header/footer again and again.
Included in the header is a further include for a css tab menu (menu.php) that i'd like to have change dependant on the page loaded.
I have split the the active and non-active links of the header into arrays inside this file, like so...
PHP:
<?php
// Tab menu array
// First array to be called when
// the page is current loading a none
// linked tab title
$menu_active = array(
'Home' => '<li><span>Home</span></li>'
,'Projects' => '<li><span>Projects</span></li>'
,'Guides' => '<li><span>Guides</span></li>'
,'Other' => '<li><span>Other</span></li>'
);
// Second array is called for page
// not currently in view
$menu_page = array(
'Home' => '<li><a href="index.php">Home</a></li>'
,'Projects' => '<li><a href="#">Projects</a></li>'
,'Guides' => '<li><a href="#">Guides</a></li>'
,'Other' => '<li><a href="#123">Other</a></li>'
,'' => '<li><a href="#">None</a></li>'
);
?>
In the header is the following....
PHP:
<div id="tabs">
<ul>
<?php
echo
$menu_active['Home'],
$menu_page['Projects'],
$menu_page['This'],
$menu_page['That'],
?>
</ul>
</div>
Inside the content.php i have the following.... (early stage)
PHP:
<?php
$page = $_GET['page'];
if ($page=="")
{ $page = "projects/index.php"; }
switch($page){
case "1":
include('projects/1.php');
case "2":
include('projects/2.php');
}
$blah = $_GET['page'];
if ($blah=="")
{ $blah = "blah/index.php"; }
switch($blah){
case "1":
include('blah/1.php');
case "2":
include('blah/2.php');
}
?>
Secondly how do i then have the menu check to see if $page of $blah has been called.
As said, i know only little about php, and this is some of what i've been learning over the last few days.
I've found it hard to find a guide that isn't too basic or too advanced to help, though some have given me pointers, they don't really apply to what i'm wanting to do.
I'm wanting to create a site with PHP, HTML and CSS, no database for my personal projects and/or guides etc...
I can find info on using case/switch to change the content, but do not know how to check what the value or variable is to display different code into the menu.
I think i need something that simple says.....
If page is equal to index....
PHP:
<?php
echo
$menu_active['Home'],
$menu_page['Projects'],
$menu_page['Guides'],
$menu_page['Other'],
?>
PHP:
<?php
echo
$menu_page['Home'],
$menu_active['Projects'],
$menu_page['Guides'],
$menu_page['Other'],
?>
Sorry for the long winded post, trying to explain best i can....
If anyone has any pointers, links or suggestions they are all welcome, thanks...