By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,304 Members | 1,253 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,304 IT Pros & Developers. It's quick & easy.

Using PHP to manipulate HTML tags

P: 2
Hello,

I'm very new to PHP, but I'm trying to come up with a way in which I can store HTML tags, or ideally whole .css files in a database, then call these through a link on a webpage, and have the formatting change as a result.

I have managed to get as far as beign able to upload all the schpeel i need into the database, but can't get my head around how to parse this into html via PHP

Any help much appreciated!

Wibble!
Apr 25 '07 #1
Share this Question
Share on Google+
3 Replies


tolkienarda
100+
P: 316
Hello,

I'm very new to PHP, but I'm trying to come up with a way in which I can store HTML tags, or ideally whole .css files in a database, then call these through a link on a webpage, and have the formatting change as a result.

I have managed to get as far as beign able to upload all the schpeel i need into the database, but can't get my head around how to parse this into html via PHP

Any help much appreciated!

Wibble!
i would love to help
a couple questions first
are these css files that are stored in the database or are they the text that makes up the css files.

now to help here is how you generate html content.
use the print or echo tags

either

[PHP]
echo '<img src="an/image.jpg" />';
[/PHP]
if you display multiple strings then they are coma delimiated
if you want to use the print tag it is the same just replace the echo with with print and new strings are connected with a '.' ok hope this helps

eric
Apr 25 '07 #2

P: 2
Cheers for the reply sofar!

At the mometn, I've just got individual tags, or options thereof stored, I'm having issues uploading whole files to the database, so as it stands the text that makes up the .css would be the easiest way probably......

Regards

Wibble
Apr 25 '07 #3

tolkienarda
100+
P: 316
Cheers for the reply sofar!

At the mometn, I've just got individual tags, or options thereof stored, I'm having issues uploading whole files to the database, so as it stands the text that makes up the .css would be the easiest way probably......

Regards

Wibble
ok you need a new collom as type BLOB this holds binary information aka files. the easiest way to manage databases on a system is with phpmyadmin. if you don't have it i strongly suggest you get it, it is stable, secure, and totaly free.

now once you have this collom you can add entire files and then use mysql select statements to get these files.

now i do think there is a better way to solve this problem than with mysql. you could have a series of .css files like follows
css1.css
css2.css
css3.css
...

and just save these on your server like you regularly would. then use a php script to determine which one to put in... say you have someone select from a dropdown box which .css file they want. it would send a variable to the
trialscript.htm
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <title>trial thing</title>
  4. </head>
  5. <body>
  6. <form action="phpscript.php" method="post">
  7. <select name="css_skin">
  8. <option value="1">css1</option>
  9. <option value="2">css2</option>
  10. <option value="3">css3</option>
  11. </select>
  12. <input type="submit">
  13. </form>
  14. </body>
  15. </html>
  16.  
phpscript.php
[PHP]
<html>
<head>
<title>page with varying skins</title>
<?
$css=$_POST['css_skin'];
echo "<html tag for css target=", $css, "close the tag>";
?>
</head>
<body>
now this could be the same page that the form was on just for the form action print out <?= PHP_SELF ?>
and then just have that php code at the top of your page
</body>
</html>

[/PHP]

hope this helps

eric
Apr 26 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.