Using PHP to manipulate HTML tags

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • wibblefish
    New Member
    • Apr 2007
    • 2

    Using PHP to manipulate HTML tags

    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!
  • tolkienarda
    Contributor
    • Dec 2006
    • 316

    #2
    Originally posted by wibblefish
    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

    Comment

    • wibblefish
      New Member
      • Apr 2007
      • 2

      #3
      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

      Comment

      • tolkienarda
        Contributor
        • Dec 2006
        • 316

        #4
        Originally posted by wibblefish
        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
        Code:
        <html>
        <head>
        <title>trial thing</title>
        </head>
        <body>
        <form action="phpscript.php" method="post">
        <select name="css_skin">
        <option value="1">css1</option>
        <option value="2">css2</option>
        <option value="3">css3</option>
        </select>
        <input type="submit">
        </form>
        </body>
        </html>
        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

        Comment

        Working...