PHP and MYSQL

Cool Cr@cker

I am now Chrono Cr@cker
  • 1,778
    Posts
    21
    Years
    Hi Guys Recently I've heard a lot about PHP and MYSQL!I've heard that these are very useful.But I
    know only HTML and JAVASCRIPT.Can anyone brief me about these.What they are and How they work!
    And how I can use them to enhance my site!!!
    Thanks!
    --Cool Cr@cker
     
    Err... mySQL really isn't needed... that's more efficient if you're storing huge loads of information...

    php has it's uses, one of which is making your site dynamic. There's another thread in here that has a bunch of ways to do that...
     
    Hmm..It's not that JK.just that I want to know 'bout them!What do you mean by Dynamic!It does sound explosive.And Can you give me the link to the other thread.
    Also if you know 'bout any site that has a good tut on either of them or both Please tell me!
     
    Dynamic...
    Characterized by continuous change, activity, or progress:
    In the webbing field, it means that the webpage is extremely easy to update.

    With normal HTML, if you wanted to add a link to the sidebar, you would have to do it on every page, and it's tedious work. That's where php comes into play.

    I don't really get that one code everyone seems to use, and I got one of my own.

    First, make sure you have a php compliant webhost. That's defiantly important. =p

    Okay, I'll make up a quick little webpage.
    Code:
    <html>
    <title>My Little Webpage</title>
    <body>
    <table>
    <tr><td colspan="3"><img src="banner.gif"></td></tr>
    <tr><td width="15%">
    Home<br>
    Forum<br>
    Staff<br>
    Content
    </td><td width="70%">
    Welcome to my site!  There isn't any news because I just started it. =)
    </td><td width="15%">
    <b>Affiliates</b><br>
    <a href="https://www.pokevillage.net"><img src="aff/pokevillage.gif"></a><br>
    <a href="https://www.patamon.tk"><img src="aff/patamon.gif"></a><br>
    </td></tr>
    <tr><td colspan="3">Don't steal my stuff please! *puppy dog eyes*</td></tr>
    </table>
    </body>
    </html>
    That code there will give me this page. It's a simple layout (minus the colors and stuff...)

    Now, as my site grows bigger, and I have 20 differnet content pages, it's gonna become a pain to add in a link to the sidebar. I'd have to edit all 20 pages, just to add that one link. And what happens when I want to add yet another? I have to edit all 20 pages again.

    That's where PHP comes in.

    I can turn the above single file into 3 seperate ones, and it'll make my updating life very easy. I'm gonna break it down into three files, "layout1.php", "index.php", and "layout2.php".

    On all my pages, everything up to where the main content begins is the same.
    Code:
    <html>
    <title>My Little Webpage</title>
    <body>
    <table>
    <tr><td colspan="3"><img src="banner.gif"></td></tr>
    <tr><td width="15%">
    Home<br>
    Forum<br>
    Staff<br>
    Content
    </td><td width="70%">
    That's on all my pages, so I'm gonna use php's include function. I take all that out and make it a new file, labelled "layout1.php".

    Then, I go back to index.htm and rename it to index.php. The .php at the end tells the webserver that there is php coding in there.

    So, at the moment, index.php is looking like this:
    Code:
    Welcome to my site!  There isn't any news because I just started it. =)
    </td><td width="15%">
    <b>Affiliates</b><br>
    <a href="https://www.pokevillage.net"><img src="aff/pokevillage.gif"></a><br>
    <a href="https://www.patamon.tk"><img src="aff/patamon.gif"></a><br>
    </td></tr>
    <tr><td colspan="3">Don't steal my stuff please! *puppy dog eyes*</td></tr>
    </table>
    </body>
    </html>

    I'm gonna add
    PHP:
    <?php include("layout1.php"); ?>
    to the front of the file. What the include function does is... well, include. It'll take all the code from layout1.php and stick it into index.php. So if I were to look at the source of index.php, I would see this
    Code:
    <html>
    <title>My Little Webpage</title>
    <body>
    <table>
    <tr><td colspan="3"><img src="banner.gif"></td></tr>
    <tr><td width="15%">
    Home<br>
    Forum<br>
    Staff<br>
    Content
    </td><td width="70%">
    Welcome to my site!  There isn't any news because I just started it. =)
    </td><td width="15%">
    <b>Affiliates</b><br>
    <a href="https://www.pokevillage.net"><img src="aff/pokevillage.gif"></a><br>
    <a href="https://www.patamon.tk"><img src="aff/patamon.gif"></a><br>
    </td></tr>
    <tr><td colspan="3">Don't steal my stuff please! *puppy dog eyes*</td></tr>
    </table>
    </body>
    </html>

    The exact same thing as what it looked like before I took out the beginning stuff and put it in layout1.php.

    Now, like the beginning bit, the end bit is the same throughout all my pages. So I'll take this bit here, and put it in a new file labelled layout2.php
    Code:
    </td><td width="15%">
    <b>Affiliates</b><br>
    <a href="https://www.pokevillage.net"><img src="aff/pokevillage.gif"></a><br>
    <a href="https://www.patamon.tk"><img src="aff/patamon.gif"></a><br>
    </td></tr>
    <tr><td colspan="3">Don't steal my stuff please! *puppy dog eyes*</td></tr>
    </table>
    </body>
    </html>

    And just like we did with the layout1.php file, we'll include layout2.php. So, our new index.php is gonna look like this:
    PHP:
    <?php include("layout1.php"); ?>
    Welcome to my site!  There isn't any news because I just started it. =)
    <?php include("layout2.php"); ?>

    Now I can go through all my pages and replace the code with the php includes (remember to rename the files to content.php instead of content.html) and soon enough, my site will be completely dynamic, easily changable.


    If you have any more questions, feel free to reply with 'em and I'll try to answer. =)
     
    Wow!That's brilliant tutorial!It's da bomb!It's helped me a lot!Thanks JK!You are my buddy.Yeah well were you online all yesterday cause I saw you postin in 5 forums!LOL
    *takes time to slowly read through this*Hmm...If have a doubt I'll ask you.
     
    Mmm, it's no problem. :P Glad to be of service.
     
    I tried it and it wasn't working. It showed up as:
    <?php include("layout1.php"); ?>
    Welcome to my site! There isn't any news because I just started it. =)
    <?php include("layout2.php"); ?>
    It showed the PHP code, but it was fine when it was just layout1 included with the rest. Also, my computer is dumb and the print shop was trying to open my PHP files, don't worry I got rid of that.
     
    Had to bump this topic, I need the PHP tutorial, but I'm having problems with figuring out shyper.....
     
    Pokedragonfire said:
    I tried it and it wasn't working. It showed up as:
    <?php include("layout1.php"); ?>
    Welcome to my site! There isn't any news because I just started it. =)
    <?php include("layout2.php"); ?>
    It showed the PHP code, but it was fine when it was just layout1 included with the rest. Also, my computer is dumb and the print shop was trying to open my PHP files, don't worry I got rid of that.
    Err... you're not doing the colors, are you? O.o
     
    Looking good PJ! ^-^

    So the PHP helped you out?
     
    Very much so! Now I can update my links + affiliates really quick....

    And I can can have a Pokemon of the Week on EVERY PAGE! *YAY*
     
    ^_^

    It does make it easier to update. ~_~
     
    Ya, thanks for the tutorial, it really helped!

    PS: Shyper has a GREAT page editor! You can edit it with HTML, or you can actually change the page....
     
    Well I copied what you did to see if it works, it didn't. No I didn't put any colors in though. I don't know why it didn't work, I'll try it again. :/
     
    That's strange... it should work perfectly... o.O;;;;;

    ...you do have layout2.php right?
     
    Yes, but the only thing I did different was used phtml instead of php ending. I'll go try again...
     
    Did you change the code to fit that then?

    *is kinda dumbfounded*
     
    JKaizer said:
    Did you change the code to fit that then?

    *is kinda dumbfounded*
    Yes, I even have a screenshot. I looked for mistakes, I didn't find any, but I didn't look extra hard
     
    Then, I go back to index.htm and rename it to index.php. The .php at the end tells the webserver that there is php coding in there.

    .phtml doesn't say there is php coding in there. index.phtml needs to be changed to index.php.
     
    Back
    Top