Jump to content

two HTML files for the same page?


danhodge

Recommended Posts

This should really contain a quick answer i guess, but i thought i would put it here for discussion...

 

I am making a website which is going to be the homepage of what i do later on, including programs, templates and a portfolio.

 

 

I'm doing the first draft, and i have 3 sidebars on the right, for which i used the <table> tags.

 

Although this is a fairly easy way of doing this, its filling up my notepad page by way too much :S

 

 

Is it possible for me to take out all of table HTML code, put it in a new HTML file, then link it into the original page, without it being a second page?

 

Or do i just need to deal with this kind of issue?

 

 

Thanks a lot,

Danny

Link to comment
Share on other sites

Sorry, i made a stupid mistake here, i forgot some Javascript and no PHP work from Local host <_<

 

Infact, it still doesn't work, im trying PHP again :-/

 

<?php
require($DOCUMENT_ROOT . "/public_html/table.html");
?>

 

I hate myself for googling code i don't understand <_<

Link to comment
Share on other sites

i forgot some Javascript and no PHP work from Local host

You are running the code using a server of some sort, correct? You've installed something like WAMP or MAMP, and are accessing the PHP file through http://localhost/? (or, if you are testing your code on your hosting account, this should all be set up for you assuming your hosting supports PHP.)

 

And the file that uses the <?php ?> code ends in .php?

 

Assuming that is all true... You might want to check what value the $DOCUMENT_ROOT variable holds, just to make sure the path is correct. Instead of an include, try echoing (displaying) the path and make sure it is correct:

 

<?php echo $DOCUMENT_ROOT . "/public_html/table.html"; ?>

Link to comment
Share on other sites

$DOCUMENT_ROOT is a constant that depends on your PHP setup. I want to make sure that the path to the include file that you are using is correct. For example, what if $DOCUMENT_ROOT includes "/public_html/", so your link actually looks like "your file path/public_html/public_html/table.html"? I imagine that wouldn't work.

 

Also, another thing to note based on http://php.net/manual/en/language.variables.predefined.php - I'm pretty sure you need to be using "$_SERVER['DOCUMENT_ROOT']" rather than simply "$DOCUMENT_ROOT".

Link to comment
Share on other sites

Could i ask what code you would use to do a basic include of a part of a website?

You are using the correct code (assuming you are using $_SERVER['DOCUMENT_ROOT'])

 

Can you just do what I have asked above? It's a 30 second change. This is the first step I would check, assuming you know that PHP is working. If PHP is working, then you have a path issue. Otherwise, I can't really help you and either you need to get help from someone else or drop the PHP includes idea.

Link to comment
Share on other sites

I know they are used for different things, but could PHP replace Javascript on your website with a bit of work?

Not really. While PHP can do some of the things that Javascript can, they are not interchangeable.

 

To borrow from http://answers.yahoo.com/question/index?qid=20080102151225AAlMHOC

 

The two are intended to control different things and work in completely different environments with different runtime models.

 

PHP is primarily server-side, back-end language that is used to produce web pages. PHP is interpreted by a module built into web server. The primary purpose of a PHP program is to produce text output that will become web page and perform actions such as database updates in response to input submitted from web browsers.

 

Javascript is a language that is understood by web browsers. In a nutshell, it just tells browser how to alter the web page look and behavior once it has already been rendered in the browser window. Javascript is intepreted by the browser only and usually has no direct communication with web server.

 

Javascript operates with HTML objects like buttons, DIV elements, input text fields, images, CSS styles and so on.

Link to comment
Share on other sites

Ahh okay then :)

 

Well, i think learning Javascript is still gonna be my priority - its much simpler than PHP, and more useful for what i currently need on my project :)

 

Thanks so much for all this, i only started HTML coding about a month or 2 ago, PHP is a lot to get my head around sometimes...

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...