Welcome Guest [Log In] [Register]
Search Members Calendar | Rules ZB Code Index IF Code Index
ZBCode
  • Navigation
  • ZBCode
  • Coding Support
  • Code University
  • Javascript / PHP / Including something
Hey, welcome to ZBCode, the premier coding forum for ZB. Here you fill find some of the best Invisionfree and Zetaboards Codes on the network! Unfortunately, you're sorta hovering around in guest mode at the moment; why not join in on the fun? Register an account and you can start accessing the wealth of resources we have available here. Enjoy your stay at ZBCode, and remember to tell all your friends about us; the more members, the more codes available. ;)

Interested in joining? Click here.


If you are already a member of ZBCode, feel free to login right here:

Username:   Password:
Locked Topic
Javascript / PHP / Including something
Tweet Topic Started: Apr 25 2009, 04:23 PM (221 Views)
.Deluxe Apr 25 2009, 04:23 PM Post #1


Posts:
25
Group:
Member
Member
#2,813
Joined:
Apr 16, 2009
Coding language
HTML/CSS
Well, basically, I have my HTML template in the file index.html.

Externally, I want to a file to hold this HTML drop-down menu which links to other websites in the network; as this drop down will go on each page and is likely to change often, so I don't want to have to go through every single page to edit drop down menu items, as my site has hundreds, if not thousands of pages!

Here's my HTML, can someone make it "include friendly" and please give me the line of code on how I would include it? I've tried PHP includes and javascript but to no avail so thought I might be doing something wrong?

Code:
 
<div id="dropdown">
<select name="SiteMap" onchange="window.open(this.options[this.selectedIndex].value)" size="1">
<option class="special" selected="selected">Torpix Services</option>
<option value="http://www.torpix.co.uk">Torpix UK</option><option value="http://www.discoverywebz.co.uk">Discovery Webz</option><option value="http://www.torpix.co.uk/radio">Torpix Radio</option><option value="http://www.fusionprimedesign.co.uk">Fusion Prime</option><option value="http://www.rocmail.co.uk">RocMail</option><option value="http://www.torbid.co.uk">Torbid</option>
</select>
</div>


Cheers! :)
Offline Profile Goto Top
 
rockon1824 Apr 25 2009, 05:48 PM Post #2
Member Avatar
I never know what to put for my member title. =(

Posts:
186
Group:
Member
Member
#424
Joined:
Aug 2, 2008
Coding language
HTML/CSS
Save that HTML as is in its own file. Then, in the file you want to include it in, put this where you want it to appear:
Code:
 
<?php include("example.html"); ?>
Replace "example.html" with whatever you named the other file.

Two important notes: both files must be in the same directory, and the main file (where you put the above code) must be saved as a PHP file.
Edited by rockon1824, Apr 25 2009, 05:49 PM.
Posted Image
Offline Profile Goto Top
 
Reid Apr 26 2009, 09:53 AM Post #3
Member Avatar
What? The land of the free? Whoever told you that was your enemy.

Posts:
1,790
Group:
Distinguished Coder
Member
#148
Joined:
Jul 20, 2008
Indeed. If they aren't in the same directory, you could of course just reference the file otherwise, couldn't you?
The Resource Board
Offline Profile Goto Top
 
.Deluxe Apr 27 2009, 05:17 PM Post #4


Posts:
25
Group:
Member
Member
#2,813
Joined:
Apr 16, 2009
Coding language
HTML/CSS
You see, thats what I tried, but when I ran the file uploaded and locally it didn't work :S
Offline Profile Goto Top
 
Kevin Apr 27 2009, 05:44 PM Post #5
Member Avatar


Posts:
700
Group:
Former Staff
Member
#8
Joined:
Jul 2, 2008
Coding language
HTML/CSS
Do you have PHP installed locally? Also, were any error messages given, or did it just show nothing?
Posted Image
Offline Profile Goto Top
 
Reid Apr 27 2009, 05:49 PM Post #6
Member Avatar
What? The land of the free? Whoever told you that was your enemy.

Posts:
1,790
Group:
Distinguished Coder
Member
#148
Joined:
Jul 20, 2008
You could try it on http://www.ripway.com/ - they offer free PHP hosting (with a 30mb daily bandwidth limit I believe)
The Resource Board
Offline Profile Goto Top
 
.Deluxe Apr 28 2009, 09:28 AM Post #7


Posts:
25
Group:
Member
Member
#2,813
Joined:
Apr 16, 2009
Coding language
HTML/CSS
I found the problem, it was because the pages where I was using the PHP include were saved as a *.html format. I rectified by changing all the page extension names to *.php and it worked wonders. :D
Offline Profile Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · Code University · Next Topic »
Locked Topic

Track Topic · E-mail Topic Time: 7:48 PM Jul 10
Hosted for free by ZetaBoards · Privacy Policy