Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: coding help

  1. #1
    New to the CF scene
    Join Date
    May 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    coding help

    I wanted to know if you could use php or javascript so you could write a script so the script creates the page itself from something like a template but with variables.

  • #2
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    Yeah.

  • #3
    Senior Coder whizard's Avatar
    Join Date
    Jan 2005
    Location
    Philadelphia, PA, USA
    Posts
    1,662
    Thanks
    14
    Thanked 76 Times in 76 Posts
    Yes, you can. However, this is really not an HTML/CSS issue. What I generally do when I am doing this is I write up my entire HTML page, style it, and then take that and apply PHP code to it. The way PHP works is it is interpreted (run) before the page is sent to the browser, and the result of running the PHP code is what is sent to the browser.

    So, for example, I can take this basic HTML page:
    Code:
    <html>
     <head>
      <title>This is my site.</title>
     </head>
     <body>
      <p>Hello World!</p>
     </body>
    </html>
    and add PHP to it like this:

    Code:
    <html>
     <head>
      <title><?php print $title; ?></title>
     </head>
     <body>
      <p>Hello <?php print $userName; ?></p>
     </body>
    </html>
    and save that as a .php file, and you can see that a title and welcome text will be added dynamically.


    Dan
    PHP Tip: If you want to use short tags (<? or <?=$var) then make sure short_open_tag is set to "1". It really helps.

    Don't forget to save everyone time and mark your thread as Resolved :)

    "Also note that it is your responsibility to die() if necessary."

    DON'T USE THE MYSQL_ EXTENSION


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •