Jump to content

PHP Coding


csgcarl

Recommended Posts

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

Link to comment
Share on other sites

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.
Link to comment
Share on other sites

[!--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 etc

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

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.php
Contact      http://www.blah.com/contact.php
Forum        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.

Link to comment
Share on other sites

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
[code]
<?php require_once('./include_links.php'); ?>
[/code]
you can then call the defined variables anytime you need them

Lev

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.