The PokéCommunity Forums

The PokéCommunity Forums (https://www.pokecommunity.com/index.php)
-   Off-Topic (https://www.pokecommunity.com/forumdisplay.php?f=23)
-   -   PHP and MYSQL (https://www.pokecommunity.com/showthread.php?t=15670)

Cool [email protected] August 22nd, 2004 5:20 AM

PHP and MYSQL
 
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 [email protected]

aRedMoon August 22nd, 2004 5:27 AM

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...

Cool [email protected] August 22nd, 2004 7:01 AM

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!

aRedMoon August 22nd, 2004 8:28 AM

Dynamic...
Quote:

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="http://www.pokevillage.net"><img src="aff/pokevillage.gif"></a><br>
<a href="http://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="http://www.pokevillage.net"><img src="aff/pokevillage.gif"></a><br>
<a href="http://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 Code:

<?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="http://www.pokevillage.net"><img src="aff/pokevillage.gif"></a><br>
<a href="http://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="http://www.pokevillage.net"><img src="aff/pokevillage.gif"></a><br>
<a href="http://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 Code:

<?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. =)

Cool [email protected] August 22nd, 2004 5:38 PM

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.

aRedMoon August 23rd, 2004 7:12 AM

Mmm, it's no problem. :P Glad to be of service.

Pokedragonfire August 23rd, 2004 7:16 AM

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.

pokejungle August 25th, 2004 6:22 AM

Had to bump this topic, I need the PHP tutorial, but I'm having problems with figuring out shyper.....

aRedMoon August 25th, 2004 6:39 AM

Quote:

Originally Posted by Pokedragonfire
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

pokejungle August 25th, 2004 7:01 AM

OMgosh!!!!


IT ACTUALLY WORKS!!!!!!!! w00t!

Sorry, things don't usually work right for me.....^^

wow! you guys can check out my site at http://pokejungle.shyper.com

aRedMoon August 25th, 2004 7:03 AM

Looking good PJ! ^-^

So the PHP helped you out?

pokejungle August 25th, 2004 7:12 AM

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*

aRedMoon August 25th, 2004 7:13 AM

^_^

It does make it easier to update. ~_~

pokejungle August 25th, 2004 7:17 AM

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....

Pokedragonfire August 25th, 2004 9:32 AM

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. :/

aRedMoon August 25th, 2004 9:35 AM

That's strange... it should work perfectly... o.O;;;;;

...you do have layout2.php right?

Pokedragonfire August 25th, 2004 9:40 AM

Yes, but the only thing I did different was used phtml instead of php ending. I'll go try again...

aRedMoon August 25th, 2004 9:40 AM

Did you change the code to fit that then?

*is kinda dumbfounded*

Pokedragonfire August 25th, 2004 9:44 AM

1 Attachment(s)
Quote:

Originally Posted by JKaizer
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

aRedMoon August 25th, 2004 9:45 AM

Quote:

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.

Pokedragonfire August 25th, 2004 9:48 AM

1 Attachment(s)
Quote:

Originally Posted by JKaizer


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

There. I changed them all to php. Still nothing.

aRedMoon August 25th, 2004 9:51 AM

Do you have Apache and php installed on your machine?

Pokedragonfire August 25th, 2004 9:53 AM

1 Attachment(s)
Beats me. But it did work at first. Just without the second one. So I'm guess I do. Plus I have the layout1 and 2. Maybe those are the problems.

aRedMoon August 25th, 2004 10:04 AM

I see nothing wrong... X_x;;

There's nothing wrong with the coding... I'm pretty sure your machine doesn't have it installed. You'd have to have installed it yourself, and most of the time it's just easier to get webspace.

Try uploading it to the a php compliant host... then we'll see where the error is. ^_^

Pokedragonfire August 25th, 2004 10:07 AM

I have no idea if comcast supports php or not, I'll upload it anyway. If it works then I guess the problem is solved. Anyway, how would I install it in case it is my computer?


All times are GMT -8. The time now is 4:52 PM.


Like our Facebook Page Follow us on Twitter © 2002 - 2018 The PokéCommunity™, pokecommunity.com.
Pokémon characters and images belong to The Pokémon Company International and Nintendo. This website is in no way affiliated with or endorsed by Nintendo, Creatures, GAMEFREAK, The Pokémon Company or The Pokémon Company International. We just love Pokémon.
All forum styles, their images (unless noted otherwise) and site designs are © 2002 - 2016 The PokéCommunity / PokéCommunity.com.
PokéCommunity™ is a trademark of The PokéCommunity. All rights reserved. Sponsor advertisements do not imply our endorsement of that product or service. User generated content remains the property of its creator.

Acknowledgements
Use of PokéCommunity Assets
vB Optimise by DragonByte Technologies Ltd © 2023.