I've been trying to create a template-based site on my XAMPP server, but it hasn't come to much!

I saved http://www.wyvernfm.co.uk/schedule.asp as testpage.htm using Opera (best browser for saving webpages in!) but am not sure how to set variables in a PHP template for the presenters and images so that rather than changing the page manually (testpage.htm) everytime, I just need to create a new PHP file with the variables in, using the original testpage.htm as the template.

I'm new to this, so any advice is appreciated ;)

Recommended Answers

All 4 Replies

I'm going to assume that you know something about PHP otherwise you need to do a tutorial.

You can add a PHP section at the very start of the module enclosing it in <?PHP and ?> statements. You could include your variables there initially and then move them out to a separate included module when you have it working reasonably well.

In the html code, you will need to include PHP sections wherever you want to include one of your variables. each of those will look something like:

html...<?PHP echo $x ?>...html
an example:
background: url(../images/whitetop_728x4-80.png) no-repeat;
becomes:
background: url(<?PHP echo $back ?>) no-repeat;

if you want to include some logic based on your variables then you will need something like:

<?PHP
if ($var == "xxx") {
echo "<a href=... ";
} else {
echo "<a href= ... ";
}
?>

You must rename the module to have a .php suffix rather than .htm

Chris

I'm going to assume that you know something about PHP otherwise you need to do a tutorial.

You can add a PHP section at the very start of the module enclosing it in <?PHP and ?> statements. You could include your variables there initially and then move them out to a separate included module when you have it working reasonably well.

In the html code, you will need to include PHP sections wherever you want to include one of your variables. each of those will look something like:

html...<?PHP echo $x ?>...html
an example:
background: url(../images/whitetop_728x4-80.png) no-repeat;
becomes:
background: url(<?PHP echo $back ?>) no-repeat;

if you want to include some logic based on your variables then you will need something like:

<?PHP
if ($var == "xxx") {
echo "<a href=... ";
} else {
echo "<a href= ... ";
}
?>

You must rename the module to have a .php suffix rather than .htm

Chris

I did rename the file to .php but I'm not sure what to do, being a beginner at PHP, only knowing simple scripts.

It can be frustrating when you're first learning a language and trying to make something work. I think that this forum is intended to provide help and advice but you need some basic understanding of PHP or the advice may not even make any sense. There are lots of sources on the internet for tutorials. You can also find some info and examples for what you are currently trying to do. An example is at: One Example

Chris

It can be frustrating when you're first learning a language and trying to make something work. I think that this forum is intended to provide help and advice but you need some basic understanding of PHP or the advice may not even make any sense. There are lots of sources on the internet for tutorials. You can also find some info and examples for what you are currently trying to do. An example is at: One Example

Chris

Thank you Chris.
I can do basic PHP scripts, and understand it OK, having learnt how to create simple login scripts, and upload scripts, plus installs of PHPBB/MediaWiki.

I've been looking through and learning PHP, but trying to do templating is a nightmare though.

I'll start a new thread with what I think are some of my best and let people judge my efforts, to see if I'm getting better.

As for that link - thanks! Should work, but whether it does for variables... I'll see!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.