csgcarl Posted June 5, 2006 Share Posted June 5, 2006 Hi, im new to this site just been told about it.Well my question is I have a site done in html and another part of site which is php is it possible to like to change the html to php? like is it easy and how would you do it?ThanksCarl Quote Link to comment https://forums.phpfreaks.com/topic/11264-php-coding/ Share on other sites More sharing options...
.josh Posted June 5, 2006 Share Posted June 5, 2006 well that depends. it's as easy as renaming blah.html to blah.php if you are just looking to change the extension. it's as easy as just doing echo "<b>blah</b>";for all of your lines. it really depends on what you mean by "changing it to php" as to how you would go about doing it. Quote Link to comment https://forums.phpfreaks.com/topic/11264-php-coding/#findComment-42141 Share on other sites More sharing options...
csgcarl Posted June 5, 2006 Author Share Posted June 5, 2006 [!--quoteo(post=380325:date=Jun 5 2006, 02:21 PM:name=Crayon Violent)--][div class=\'quotetop\']QUOTE(Crayon Violent @ Jun 5 2006, 02:21 PM) [snapback]380325[/snapback][/div][div class=\'quotemain\'][!--quotec--]well that depends. it's as easy as renaming blah.html to blah.php if you are just looking to change the extension. it's as easy as just doing echo "<b>blah</b>";for all of your lines. it really depends on what you mean by "changing it to php" as to how you would go about doing it.[/quote]Sorry should have explained it more, well basicly we have a gaming ladder script which is php and ive noticed how easy it is e.g. if you say need to change a link on one page it adds it to all pages instead of html where we would have to go back through all the pages changing them.I dont know how easy it would be to add php pages to the script so there all php (so like I say I can change 1 link and it changes them all etc.) But when I look at the php script files there not like page named 'home' and you open it and its got all the stuff on home page, so I was just wondering how I would ad pages in php etcIf this makes sence [img src=\"style_emoticons/[#EMO_DIR#]/unsure.gif\" style=\"vertical-align:middle\" emoid=\":unsure:\" border=\"0\" alt=\"unsure.gif\" /] Quote Link to comment https://forums.phpfreaks.com/topic/11264-php-coding/#findComment-42145 Share on other sites More sharing options...
.josh Posted June 5, 2006 Share Posted June 5, 2006 if you have a link on a page and you wish to be able to change it on all the pages, you would store the link in a database and then in place of the hardcoded link, you would retrieve the link from the database and display the variable. for example: if you might have a table called links and 2 columns called link_name and link_url[code] Links =====Link_Name Link_URL---------------------Home http://www.blah.com/home.phpContact http://www.blah.com/contact.phpForum http://www.blah.com/forum.php[/code]you would then query the database, like[code]//after connecting to the database...$query = "select * from Links where Link_Name='Home' ";$rs = mysql_query($query);$info = mysql_fetch_array($rs);echo "<a href='".$info['Link_URL']."'>".$info['Link_Name']."</a>";[/code]this would echo a link the same way as doing <a href='http://www.blah.com/home.php'>Home</a>so if you have that in all your pages, simply changing the Link_URL in the database would change the link in all of the pages. now, depending on what your links are for, would determine how you would actually setup your database table, retrieve the information, and display it. Quote Link to comment https://forums.phpfreaks.com/topic/11264-php-coding/#findComment-42175 Share on other sites More sharing options...
Levan Posted June 6, 2006 Share Posted June 6, 2006 I am only new to this PHP stuff and feel free to explain why this way is not as effective as the method using a database could you create a php file called for eg link.phpin which you define variables which define the links...ie $home_page=".\somewhere\home.php$link_page=".\somewhere\link.phpand then include this file and call the variables when you need them....then you just update your include file as requiredLevOoops you wouldnt call the file links.php and then define it in the variablesyou would call it include_links.php or something then in the top(before the header) of each page you wanted to call the links you would do[code]<?php require_once('./include_links.php'); ?>[/code]you can then call the defined variables anytime you need themLev Quote Link to comment https://forums.phpfreaks.com/topic/11264-php-coding/#findComment-42333 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.