Jump to content

Is this possible?


sdscuba

Recommended Posts

Is it possible to contain all html code in a mysql database? Then use only php to build the web pages?

I need to create 15 subdomains that have common html code. Only a few changes exists between the subdomains. I would like to make it easy in making changes to all common code between subdomains by having a common table in the database, then have a record for each subdomain that contains the differences.

Is this something I can accomplish with php and mysql?

Thanks in advance.
Link to comment
Share on other sites

Preferably, I'd do something like this:

[b]common_html.php[/b]:
[code]<?php
function addHeader($title) {
?>
<html>
<head>
  <title><?php echo $title; ?></title>
  <!-- etc.. -->
<?php
}

function addBody() {
?>
<body>
<!-- etc.. -->
<?php
}
?>[/code]

Eg, [b]index.php[/b]:
[code]<?php
include 'common_html.php';

addHeader("Home page");
echo "Some other stuff to go on the header\n</head>";

addBody();
echo "Some stuff to go on the homepage!\n</body>\n</html>";
?>[/code]
Link to comment
Share on other sites

[quote author=vbnullchar link=topic=110050.msg444178#msg444178 date=1159613027]
its possible, but why would u do that... I suggest that you go for a template page
ex..
<html>
<head><title>{title}</title></head>
</html>
then just replace {title} with the title of the the current page
[/quote]

My idea was to have all common html code in a database so that when a change needs to be made, I change it once in the database so that all subdomain websites are updated at once. Using a template would mean me changing the common html in all subdomains.
Link to comment
Share on other sites

[quote author=FrOzeN link=topic=110050.msg444209#msg444209 date=1159622891]
Preferably, I'd do something like this:

[b]common_html.php[/b]:
[code]<?php
function addHeader($title) {
?>
<html>
<head>
  <title><?php echo $title; ?></title>
  <!-- etc.. -->
<?php
}

function addBody() {
?>
<body>
<!-- etc.. -->
<?php
}
?>[/code]

Eg, [b]index.php[/b]:
[code]<?php
include 'common_html.php';

addHeader("Home page");
echo "Some other stuff to go on the header\n</head>";

addBody();
echo "Some stuff to go on the homepage!\n</body>\n</html>";
?>[/code]
[/quote]


Understood. I think this is the approach I am looking for. Thanks!  :-)
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.