Web Design Forums

PHP

Have questions about PHP? Ask them here and our experts will assist you before you know it! You can also find help in the documentation at PHP.net.

how to update page content on another page automatically



Site of the Month Voting - Now Open. CAST YOUR VOTE NOW!

Reply
 
LinkBack Thread Tools
Old March 18 '08, 11:31 PM (#1)
ketanco is offline
WDF Regular
 
ketanco's Avatar
 
Join Date: October 2007
Posts: 228
ketanco is an unknown quantity at this point
how to update page content on another page automatically

Hi,
Might be a basic question but, I am a novice designer.
How do you transfer a certain part of code that you write on one page automatically to other pages?
For example, the button links on my home page, I want them to repeat on many pages. But when I change anything about that code at home page, I gotta go to all individual pages and change all of them. How do you automatically update the other pages? As much detail as possible and any examples are appreciated.
Thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old March 19 '08, 05:19 AM (#2)
bfsog is offline
Coder
 
bfsog's Avatar
 
Join Date: May 2003
Location: UK
Posts: 2,354
bfsog is a splendid one to beholdbfsog is a splendid one to beholdbfsog is a splendid one to beholdbfsog is a splendid one to beholdbfsog is a splendid one to beholdbfsog is a splendid one to beholdbfsog is a splendid one to behold
Send a message via MSN to bfsog
Hello and welcome to WDF.

There are various ways to achieve this.

I posted a similar response a while back, Including Files

In short

1) Use a .js file. Example: save the below as code.js
Code:
document.write("<p>Hello, I am a paragraph.");
And where you want the outout to appear place this line of code:
HTML Code:
<script src="code.js"></script>
2) PHP includes. Save the code that will be repeated in a separate file (such as menu.html) and if you have a host with PHP enabled have the following code.
PHP Code:
include("menu.html"); 
Other server side languages have similar means.

Read the thread I linked to.

Good luck.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old March 19 '08, 11:31 AM (#3)
mlseim is offline
WDF Staff
 
mlseim's Avatar
 
Join Date: April 2004
Location: Cottage Grove, Minnesota
Posts: 3,359
mlseim has much to be proud ofmlseim has much to be proud ofmlseim has much to be proud ofmlseim has much to be proud ofmlseim has much to be proud ofmlseim has much to be proud ofmlseim has much to be proud ofmlseim has much to be proud ofmlseim has much to be proud ofmlseim has much to be proud of
You can create another PHP script called "nav.php"

On each of your pages, you have this where you want it to appear:
<?php include("nav.php")?>

Within the script called "nav.php", you test the URL of the
page that is using it, and modify your style for the appropriate
navigation buttons ... this is all done using PHP scripting.

That makes the navigation work properly ... perhaps you want to highlight
the button on the current page that is being viewed?

Your post here is in PHP, but we're not sure of your PHP level (abilities).
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old March 19 '08, 09:38 PM (#4)
ketanco is offline
WDF Regular
 
ketanco's Avatar
 
Join Date: October 2007
Posts: 228
ketanco is an unknown quantity at this point
Thanks for the answers...
To bfsog: the php worked properly....but to js although I pasted the exact same html code, it did not display the menu items, links etc... it worked as the exaple you wrote though (just the paragraph)

To mlseim: yes I would love to highlight the button on the current page that is viewed.. how can I do that at the same time updating that menu automatically (which I can do now)? my php skill is beginner level.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old March 20 '08, 07:16 AM (#5)
bfsog is offline
Coder
 
bfsog's Avatar
 
Join Date: May 2003
Location: UK
Posts: 2,354
bfsog is a splendid one to beholdbfsog is a splendid one to beholdbfsog is a splendid one to beholdbfsog is a splendid one to beholdbfsog is a splendid one to beholdbfsog is a splendid one to beholdbfsog is a splendid one to behold
Send a message via MSN to bfsog
Hello ketanco,

I am not sure what you have tried, but I made a quick demo and put it online, http://andrewbuchan.co.uk/testing/usingj***ternally/

If you view the source of menu.js there are some tips there.

Good luck.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old March 20 '08, 08:58 AM (#6)
mlseim is offline
WDF Staff
 
mlseim's Avatar
 
Join Date: April 2004
Location: Cottage Grove, Minnesota
Posts: 3,359
mlseim has much to be proud ofmlseim has much to be proud ofmlseim has much to be proud ofmlseim has much to be proud ofmlseim has much to be proud ofmlseim has much to be proud ofmlseim has much to be proud ofmlseim has much to be proud ofmlseim has much to be proud ofmlseim has much to be proud of
Ketanco ...

Below is a simplified PHP script that would check for the current
page displayed and determine whether or not to make it a link.

You can code any type of CSS (styles) or whatever to highlight your links,
or to highlight the current page.

This script might be called "nav.php":
PHP Code:
<?php

// Get the current web page filename
$cur basename($_SERVER[PHP_SELF]);

if(
$cur == "index.php"){
echo 
"<b>HOME</b>";
}
else{
echo 
"<a href='index.php'>HOME</a>";
}

if(
$cur == "about.php"){
echo 
"<b>ABOUT US</b>";
}
else{
echo 
"<a href='about.php'>ABOUT US</a>";
}

if(
$cur == "contact.php"){
echo 
"<b>CONTACT</b>";
}
else{
echo 
"<a href='contact.php'>CONTACT</a>";
}

?>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

  Web Design Forums » Programming Help » PHP

Bookmarks


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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Layout Basics JR Coding Articles & Tutorials 13 April 29 '05 11:02 AM
OFFICIAL: Page Rank Update 4/21 goldsgym Search Engine Optimization / SEO 3 April 22 '05 03:15 AM
Scrollbar shifting page Delerium HTML and CSS Help 5 October 19 '03 05:19 PM
Possible to change <div> content without re-loading page? skywater Javascript, AJAX, and JSON 6 July 2 '03 03:48 PM
please help tctguy For Hire / Wanted 3 June 25 '03 04:59 PM

 
User Infomation
Your Avatar

Site Of The Month
Nominate Your Site Now!

Advertisement
WolfCMS.org

Latest Articles
- by RickM
- by bfsog

Advertisement

Partner Links



All times are GMT -4. The time now is 02:13 PM.


WebDesignForums.net is Copyright © 2010 RikeMedia.

SEO by vBSEO

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164