PDA

View Full Version : PHP Help


Juggaloca
12-30-2002, 06:12 PM
Hey well i have almost the same problem as the "PHP Directing" Post bu i dont understand his explanation,

well i followed everything at http://sskys.net/main.php?id=php and when i click on the link i set up nothing comes up, these are the instructions i followed
==============================================
Step 0: Make a site out of regular HTML

Step 1: Open your webpage with a text editor. Cut the content in the page and

paste it onto another txt document.

Step 2: In place of the content put <?php include ("$id.extention"); ?>

Step 3: Rename that file main.php.

Step 4: Save the place where you copied your content to whatever you want.

Step 5: Now lets make a page so that we can direct main.php somewhere. Create a new page, now all you need to put into the new page is something like this:
<p><b>Title Of Page </b></p>
<p> Content Of The Page Here</p>

==============================================

this is what my conding looks like( some of it was taken out cuz its so long)

==============================================
<html>
<body bgcolor=000000 text=FFFFFF>

.........

..::Menu::..
.........

<a href=main.php?id=rule>Rules</a><br>

.......

</td>
<td>

<?php include ( $id.extension ); ?>

............
</div>
</html>
==============================================

the problem is the content will not show i have the txt file ready and it will not shown wheni clikc the link some one plz help

mkauk
12-30-2002, 07:34 PM
<?php if ($page=="Home") { include ("news.php"); } ?>


and the link will be <a href="main.php?page=Home">Home</a>

Juggaloca
12-30-2002, 08:01 PM
<html>
<body bgcolor=000000 text=FFFFFF>
<style type="text/css">
<!--
table
{background-repeat:no-repeat;}
--!>
</style>


<style type=text/css>
<!--
a:link
{text-decoration:none; color=FFFFFF}
a:active
{text-decoration:none; color=FFFFFF}
a:visited
{text-decoration:none;color=FFFFFF}
a:hover
{text-decoration:underline overline color=FFFFFF;}
--!
</style>


<div id="Layer1" style="position:absolute; left:0px; top:0px; z-index:4"><img src="cjtop.gif"></div>

<div id="Layer2" style="position:absolute; left:0px; top:120px; z-index:4">
<table width=500 bordercolor=660000 marginwith=0 cellpaddinf=0 cellspacing=0 border=1px>
<tr>
<td background=cjside.gif height=500 width=137 valign=top align=center>

..::Menu::..<br>
<a href=news.html target=1>News</a><br>
<a href=info.htm target=1>Info</a><br>

<a href=main.php?page=rule.txt>Rules</a><br>

<a href=join.htm target=1>Join</a><br>
<a href=history.htm target=1>History</a><br>

..::Members::..<br>
<a href=members.htm target=1>Members</a><br>
<a href=council.htm target=1>Council</a><br>
<a href=meetings.htm target=1>Meetings</a><br>
<a href=tournaments.htm target=1>Tourneys</a><br>
<a href=br.htm target=1>Battle Reports</a><br>
..::Interaction::..<br>
<a href="http://pub41.bravenet.com/forum/show.php?usernum=3439984039&cpv=1" target=new>Forum</a><br>
<a href=chat.htm>Chat</a><br>
<a href=guestbook.htm>GuestBook</a><br>
..::Ranking::..<br>
<a href=ranks.htm target=1>Ranks</a><br>
<a href=broodwar.htm target=1>Broodwar</a><br>
<a href=starcraft.htm target=1>Starcraft</a><br>
<a href=points.htm target=1>Points</a><br>
<a href=pleaders.htm target=1>Point Leaders</a><br>
..::Diplomacy::..<br>
<a href=allies.htm target=1>Allies</a><br>
<a href=enemies.htm target=1>Enemies</a><br>
..::Downloads::..<br>
<a href=maps.htm target=1>Maps</a><br>
<a href=replays.htm target=1>Replays</a><br>
<a href=pictures.htm target=1>Pictures</a><br>
</td>
<td>

<?php if ($page=="Home") { include ("news.php"); } ?>

</td>
</table>
</div>
</html>



ok thats my code do i just do the same thing for all links like i did for rules ? and what do i change where the content goes ?

mkauk
12-30-2002, 08:09 PM
if you want all your link like that add another line of this code
if ($page=="Home") { include ("news.php"); }

but chand it to like
if ($page=="Downloads") { include ("downloads.php"); }

and your link url will be

main.php?page=Downloads


and in the url the main.php will be whatever page the code is in

so link would be index.php if that codes in the file index.php

Juggaloca
12-30-2002, 08:30 PM
I cant get it to work ! I donno what im doing wrong

mkauk
12-30-2002, 11:08 PM
just wondering if your saving the file as.. .php

Juggaloca
12-30-2002, 11:41 PM
well i have folowed the instructions from the webpage first mentioned and yes i renamed the main file to php and then i got the content in a file named rule.txt

Juggaloca
12-31-2002, 04:37 AM
Thank you mkauk for bothering to answer my post and make an effort to help me iev figured it out and not it works perfectly thank you i apreciate your help

sskys
12-31-2002, 05:00 AM
Alright... can anyone help me with this... I have had several people ask about that Tutorial... can someone make one for me that explains more... but is easyer to understand...

Thanks a lot

Juggaloca
12-31-2002, 05:49 AM
The next post is what I did to mine

View my webpage PHP my first PHP site yay

http://www.hostultra.com/~juggaloca/main.php?page=news

and yes i know its not much to look at on it still work in porgress

Juggaloca
12-31-2002, 05:50 AM
ok you got every thing right exept the intead

<?php include ("$id.extention"); ?>

of that you put this

<?php if ($page=="samename ") { include ("filename.txt"); } ?>

<a href=main.php?page=samename >News</a><br>

Jochem
12-31-2002, 10:26 AM
Tutorial on how to INCLUDE pages

Ok, so it seems there are quite a lot of people that have problems including pages on their index page...so i'll try to explain it here, allthough i'm not that good in english...:cool:

Here it goes:
If you don't want to use any frames or iframes the next thing to do is....using the include feature of PHP.
To include a page on your index page (we'll name our index page "index.php), the index page needs to know what page to include before it'll be able to include a page, quite logical i think..
Therefor you need a variable. You can give the variable (which identifies a part of your computer memory) a name, doesn't really matter how you call it, as long as you keep using the same name over and over again in the same script...otherwise it won't work..

Now, I always call it option or page, i'd go for option (its my fav name for this variable :p). Now we can store a string into this variable...(a string: some characters, that does make a word together...or even a whole sentence..). This is necessary to let the page know which page to incude..e.g. if you want to include a news page, you can store the word "news" into this variable. If you want to include a link page, you can store the word "link" into this variable...

Now, lets say we want to include a news page. First thing we have to do, as i just mentioned, is store the word "news" into the variable....We will do so, after the user, or visitor (or however you wanna call it..i'll call it user from now on), clicks the news link.
This is how the link will look if we go store the word into the var:

<a href="index.php?option=news">news</a>

As soon as the user clicks the link, the word "news" will be stored into the var. "option", and as you might have noticed, its a link that goes to the same index.php as we are allready on..

Now....to let the page know what other page to include, we have to compare the string that is stored into the var. with another string..DO THIS AT THE PLACE WHERE YOU WANT TO INCLUDE THE NEWS PAGE.

the code will be as followed:

<? if ($option=="news") { include ("news.php"); } ?>

a little explanation..: ($option=="news") compares the string "news" with the string stored in the var "option". == means: equal to. So if the string in 'option' is equal to the string "news" (and it is, cos the word "news" was stored in the var after we clicked the link) it will execute the
include ("news.php");
code. It'll copy all text that is in the file news.php into the index.php.

well, i don't know if i explained it clearly here...but i did my best..

sskys
12-31-2002, 03:47 PM
lol, It's better than mine. So... You speak dutch right?? I COULDA USED YOU INSTALLING 4IMAGES... I had to "read" dutch until I found out how to install the english pack.

("Read" is actualy clicking around untill I see what I want)

Jochem
12-31-2002, 04:58 PM
hehe, well, remember i'm a dutch guy, so if ya need to read dutch again...you know where to find me.

Square Legacy
01-01-2003, 08:31 PM
hmm I don't really get it... I understand how to get it to show up but I don't know how I would make diffrent pages show up. Ex my news page main.php?page=news
but what i don't understand is, if you have to add <?php if ($page=="Home") { include ("news.php"); } ?> to main.php to get the news to show up how do I add the content to main.php without putting both the news and the content I want on the page?

Thanks

Square Legacy
01-01-2003, 08:40 PM
Never mind. I found out what to do

Dark Hedgehog
01-04-2003, 03:06 AM
i'm gonna die learning this...oi...for the fact that I only know html and javascript...oh boy - -; in the process of learning MySQL..

Juggaloca
01-04-2003, 03:16 AM
wouldnt MYSQL be esier to learn if you knew some php in the other hand i dont know anythoign bout MySql and PHP

Dark Hedgehog
01-04-2003, 08:02 AM
does that also mean oekaki boards? OO; people can paint on it and save it on the page...OO;