I’m not sure if this is where I should put it as I’m just new here. But I just want to know if it is possible to create a .php file for the repeated content? An example would be, if I want to change the promo date of a certain coupon in the index and would like that change to take effect to all of the pages of the website by only editing the index page, how can I do it? Is it possible to do it in a .php file?
What I want is to lessen the time of editing each page and just edit the .php file instead of going through all of the 50+ pages of the website.
If this is possible, how can I do that and which particular code should I use?
I hope this question makes sense.
I really need help on this matter so any suggestions would be greatly appreciated.
I hope someone could help me on this. I really need to learn more about this as I’m trying to work on this page. I’m slowly learning PHP and I know that I still need to know more. This is somewhat complicated for me.
Just Break the page into chunks like : header,footer ,center ,a separate php page.
Include them to build a webpage, so u have change only these files.
u can also call a function to show the promocode on ur site ,where function will be in another php page.
Thank you rajeev13 for your fast reply. But may I know how I will be able to break the pages in chunks? What code should I use? I’m really new to PHP and I am really not that confident to work on these codes.
Thank you 2ndmouse for this very simple code and explanation. I kind of understand it now a little.
So on that second code, will I just put this code "include(‘updates.php’); " anywhere in each of the html page of the website? Of course in the location where I want that updates.php to appear in the webpage. Is that it?
Your index.php file should look something like this:
<?php
include('updates.php');
?>
<html><head>
</head><body>
Your content
</body></html>
If that fails, create a file named phpinfo.php, insert the following code to that page:
<?php
// Show all information, defaults to INFO_ALL
phpinfo();
?>
Upload the page to your site and run it in your browser. You should see displayed all current PHP settings on your server. If you don’t get this displayed, then it probably means that PHP is not installed on your server.
I don’t know what happened but when I opened the homepage I got this message on my screen: Parse error: syntax error, unexpected T_STRING in /home/content/08/6277108/html/airconditioningokc/updates.php on line 6
I just followed your instruction but I still get errors. So how do I install PHP in my server?
That looks like a php error, so I guess php must be installed already. Did you run the phpinfo file yet?
The image of your code is still pending approval, so I haven’t yet seen your file contents. Can you paste your file contents between
tags in your next post here, so that I can see what you have there.
Meanwhile, here's one to try:
First, create the file: updates.php with the code below and upload to your server.
```php
<?php
$promo_date = '15 FEB 2013';
?>
Then create a file: test.php and upload it to your server in the same directory as updates.php.
<?php
$promo_date = '15 FEB 2013';
$analytics_code = '<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-20639892-2']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>'
?>
I thought that I could also include the analytics code there. Because my goal was to also put the analytics code in every page through a php file so I thought this was ok.