daca Posted April 15, 2007 Share Posted April 15, 2007 Hello everyone, I really hope you can help me here, before I pull the remainder of my hair out. I can create a simple website using the code below, but if the site was to grow beyond a simple website then I would like to implement some PHP coding in it to make certain parts of it easier to update as and when is required. For instance, the links bar along the top could be likely to change as I add more sections, the cell of the table down the right hand side contains images that act as links to external sites, which will almost definitely change at times, finally the bottom cell contains the year, which obviously will need to be changed yearly. So basically those three cells need to call upon a PHP file if I am correct in thinking. If the site only had 10 pages or so, then I would quite happily leave it as a HTML site, but if it grows to have 100 pages or more, then I would really need to use PHP as a way of making the changes quickly and easily. I have been trying to follow various tutorials on the net but don't seem to be getting anywhere fast. Would anybody be able to help me? Thanks in advance. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html><head> <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type"> <title>Help Needed</title></head> <body style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);" alink="#350374" link="#350374" vlink="#350374"> <table style="text-align: left; width: 100%;" border="0" cellpadding="2" cellspacing="2"> <tbody> <tr> <td><a href="index.html"><img style="border: 0px solid ; width: 493px; height: 49px;" alt="" src="header_logo.png"></a><br> </td> <td style="width: 128px;"><img style="width: 128px; height: 48px;" alt="" src="logo.png"><br> </td> </tr> <tr style="color: rgb(255, 255, 255); font-weight: bold;" align="center"> <td style="background-color: rgb(204, 102, 204);" colspan="2"><small><span style="font-family: Arial;">Link 1</span><span style="font-family: Arial;"> </span><span style="font-family: Arial;"><big>׀</big></span><span style="font-family: Arial;"> <span style="text-decoration: underline;">Link 2</span> </span><span style="font-family: Arial;"><big>׀</big></span><span style="font-family: Arial;"> <span style="text-decoration: underline;">Link 3</span> </span><span style="font-family: Arial;"><big>׀</big></span><span style="font-family: Arial;"> <span style="text-decoration: underline;">Link 4</span> </span><span style="font-family: Arial;"><big>׀</big></span><span style="font-family: Arial;"> </span><span style="font-family: Arial;"><span style="text-decoration: underline;">Link 5</span> </span><span style="font-family: Arial;"><big>׀</big></span><span style="font-family: Arial;"> <span style="text-decoration: underline;">Link 6</span> </span><span style="font-family: Arial;"><big>׀</big></span><span style="font-family: Arial;"></span><span style="font-family: Arial;"> <span style="text-decoration: underline;">Link 7</span> </span><span style="font-family: Arial;"><big>׀</big></span><span style="font-family: Arial;"> <span style="text-decoration: underline;">Link 8</span></span></small></td> </tr> <tr> <td> <span style="font-family: Arial;">Content will go here.</span><p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus non erat eu dui dignissim dictum. Integer iaculis nulla at nisl. Proin ut enim non ipsum varius laoreet. Integer feugiat, ante fringilla blandit convallis, leo sapien egestas velit, non condimentum nulla sem vitae risus. Mauris aliquam auctor quam. Sed ac enim. Donec mattis dui id ligula. Integer vel sem eget ante cursus tristique. Nullam vel orci vitae sem interdum placerat. In eget lectus. Donec blandit. Quisque lacus urna, malesuada vel, mollis sit amet, rutrum nec, est. Proin blandit ornare nibh. Duis et felis.</p> <p>Fusce euismod nisi at libero malesuada consectetuer. Proin laoreet, nunc quis hendrerit gravida, neque leo placerat sapien, et semper tortor leo et urna. Ut tincidunt posuere tortor. Sed tristique, odio at luctus facilisis, nulla quam rhoncus tortor, at congue lacus elit nec metus. Sed tempor sapien ut elit. Donec ac turpis feugiat nisi porta vehicula.</p> <p>Aenean eu lorem at odio placerat fringilla. Cras faucibus velit quis dui. Proin scelerisque orci nec arcu. Pellentesque cursus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Nullam mattis iaculis purus. Curabitur velit. Vivamus et diam pharetra elit auctor molestie. Suspendisse potenti. Praesent enim. Vivamus at magna. Ut et dolor eu erat facilisis sollicitudin. Duis sed ante. Suspendisse lorem. Suspendisse mollis, dolor sit amet pellentesque sodales, diam risus adipiscing diam, vel ornare lorem pede ac ipsum.</p><br> <hr style="width: 100%; height: 2px;"> </td> <td style="text-align: center; vertical-align: top; width: 128px; background-color: rgb(255, 255, 153);"><img style="width: 88px; height: 15px;" alt="" src="ex_link1.png"><br> <br> <img style="border: 0px solid ; width: 80px; height: 15px;" alt="" src="ex_link2.png"><br> <br> <span style="text-decoration: underline;"></span><img style="border: 0px solid ; width: 80px; height: 15px;" alt="" src="ex_link3.png"><br> <br> <span style="text-decoration: underline;"><img style="border: 0px solid ; width: 80px; height: 15px;" alt="" src="ex_link4.png"></span><br> <br> <img style="border: 0px solid ; width: 80px; height: 15px;" alt="" src="ex_link5.png"><br> <br> <img style="border: 0px solid ; width: 80px; height: 15px;" alt="" src="ex_link.png"> </td> </tr> <tr align="center"> <td colspan="2"> <p style="font-weight: bold;" align="center"><span style="font-family: Arial;">2007</span></p> </td> </tr> </tbody> </table> </body></html> Quote Link to comment https://forums.phpfreaks.com/topic/47050-converting-a-site-from-standard-html-to-include-php/ Share on other sites More sharing options...
MadTechie Posted April 15, 2007 Share Posted April 15, 2007 erm... i have read this a few times whats the question? i think its how do i use php with templates.. :-\ Quote Link to comment https://forums.phpfreaks.com/topic/47050-converting-a-site-from-standard-html-to-include-php/#findComment-229493 Share on other sites More sharing options...
tippy_102 Posted April 15, 2007 Share Posted April 15, 2007 This is the method I use....even for sites with far fewer than 10 pages. Make a header file and a footer file. Include these files all your other files (index, link1, etc.) As an example, your index.php would look something like this: <?php include ("header.php"); // header ?> all your html code... <?php include ("footer.php"); ?> The header file will have everything above "Content will go here." You would need to edit only this file to add links, change layout etc. The footer file will include all the common things at the end of your pages, such as the closing hr tag and the year. The year can be updated automatically each year by doing this: Copyright © <? echo date("Y"); ?> The header, with the links, can be updated manually, or you could have a database containing: id, title, url Whenever you want to change a link, simply update the database, and it will magically appear on all your pages by putting something like this in your header: <?php mysql_connect("$host", "$username", "$password")or die("cannot connect server "); mysql_select_db("$db_name")or die("cannot select DB"); $sql="SELECT * FROM link_items ORDER BY id ASC"; $result = mysql_query($sql) or die ("couldn't execute query"); while ($row = mysql_fetch_array($result)) { extract($row); echo "<li><a href='$url'>$title</a> </li>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/47050-converting-a-site-from-standard-html-to-include-php/#findComment-229572 Share on other sites More sharing options...
daca Posted April 15, 2007 Author Share Posted April 15, 2007 Thanks tippy_102, you obviously grasped what I was wanting to do, unfortunately, no matter how I try, I can't put what you told me to do in to practice. I really am new to this PHP lark, and might need things dumbing down a bit for me. Quote Link to comment https://forums.phpfreaks.com/topic/47050-converting-a-site-from-standard-html-to-include-php/#findComment-229926 Share on other sites More sharing options...
ted_chou12 Posted April 15, 2007 Share Posted April 15, 2007 to start with the convertion, you need to find a php host first, and please tell us what your problem is, Thanks tippy_102, you obviously grasped what I was wanting to do, unfortunately, no matter how I try, I can't put what you told me to do in to practice. I really am new to this PHP lark, and might need things dumbing down a bit for me. doenst explain what your problem is. Ted Quote Link to comment https://forums.phpfreaks.com/topic/47050-converting-a-site-from-standard-html-to-include-php/#findComment-229929 Share on other sites More sharing options...
daca Posted April 15, 2007 Author Share Posted April 15, 2007 Oh, sorry, I know how frustrating it can be trying to help someone who is not explaining things properly. Thing is, you might of just answered my problem without realising it. You say I need to find a PHP host first. Does this mean that I can not get it all working offline on my own computer before uploading it? The actual problem is, I am no nearer to getting to where I wanted to in my first post. Quote Link to comment https://forums.phpfreaks.com/topic/47050-converting-a-site-from-standard-html-to-include-php/#findComment-229936 Share on other sites More sharing options...
ted_chou12 Posted April 15, 2007 Share Posted April 15, 2007 you need configurations for your computer before running php scripts properly, so i suggest you go find a host, http://free-webhosts.com Ted Quote Link to comment https://forums.phpfreaks.com/topic/47050-converting-a-site-from-standard-html-to-include-php/#findComment-229938 Share on other sites More sharing options...
daca Posted April 15, 2007 Author Share Posted April 15, 2007 Ok, done, I have signed up for some free hosting for now. Sorry again. So now I should be able to achieve what I am hoping to do by uploading everything to there instead of just trying it out on my computer then? Quote Link to comment https://forums.phpfreaks.com/topic/47050-converting-a-site-from-standard-html-to-include-php/#findComment-229941 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.