Jump to content


Photo

PHP Coding


  • Please log in to reply
4 replies to this topic

#1 csgcarl

csgcarl
  • Members
  • PipPip
  • Member
  • 28 posts

Posted 05 June 2006 - 07:15 PM

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?


Thanks
Carl



#2 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 05 June 2006 - 07:21 PM

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.
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#3 csgcarl

csgcarl
  • Members
  • PipPip
  • Member
  • 28 posts

Posted 05 June 2006 - 07:28 PM

[!--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) View Post[/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 etc

If this makes sence [img src=\"style_emoticons/[#EMO_DIR#]/unsure.gif\" style=\"vertical-align:middle\" emoid=\":unsure:\" border=\"0\" alt=\"unsure.gif\" /]

#4 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 05 June 2006 - 08:31 PM

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

        Links
        =====
Link_Name    Link_URL
---------------------
Home         http://www.blah.com/home.php
Contact      http://www.blah.com/contact.php
Forum        http://www.blah.com/forum.php
you would then query the database, like

//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>";

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.


Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#5 Levan

Levan
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 06 June 2006 - 08:35 AM

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.php
in which you define variables which define the links...
ie
$home_page=".\somewhere\home.php
$link_page=".\somewhere\link.php

and then include this file and call the variables when you need them....
then you just update your include file as required

Lev

Ooops you wouldnt call the file links.php and then define it in the variables
you 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
<?php require_once('./include_links.php'); ?>
you can then call the defined variables anytime you need them

Lev






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users