Help please with PHP...
Moderator: General Moderators
-
makisoustas
- Forum Newbie
- Posts: 12
- Joined: Sat Dec 18, 2010 5:11 pm
Help please with PHP...
I have a website and I am using an arcade script but I don't want to keep working on this. I want to make own script in the website. Anyway I want for example on the homepage to display thumbails of the games. When user clicks on a game he will be redirected to a page where the game will be displayed. Because I don't want to make a page for every game in html. I want with this only page to display the game that the user clicked from the homepage. How I'll do that?
Thank you!
Thank you!
- Jonah Bron
- DevNet Master
- Posts: 2764
- Joined: Thu Mar 15, 2007 6:28 pm
- Location: Redding, California
Re: Help please with PHP...
You can link to the page like this:
Then access the value of ?game with $_GET['game']. In this case, the value of $_GET['game'] would be "somegame".
Code: Select all
http://example.com/game.php?game=somegame-
makisoustas
- Forum Newbie
- Posts: 12
- Joined: Sat Dec 18, 2010 5:11 pm
Re: Help please with PHP...
Do you mean put this on the homepage for example: <a href="http://example.com/game.php?game=somegame">(Here will be placed text or image of the game)</a> and in the game page I will place this: $_GET['game'] ?? How the game page will show the game? From the database and with the "echo ()" function??Jonah Bron wrote:You can link to the page like this:
Then access the value of ?game with $_GET['game']. In this case, the value of $_GET['game'] would be "somegame".Code: Select all
http://example.com/game.php?game=somegame
And thanks for your reply!
- Jonah Bron
- DevNet Master
- Posts: 2764
- Joined: Thu Mar 15, 2007 6:28 pm
- Location: Redding, California
Re: Help please with PHP...
That's right.makisoustas wrote:Do you mean put this on the homepage for example: <a href="http://example.com/game.php?game=somegame">(Here will be placed text or image of the game)</a> and in the game page I will place this: $_GET['game'] ??
If that's where your games are stored, then yes.makisoustas wrote:How the game page will show the game? From the database and with the "echo ()" function??
-
makisoustas
- Forum Newbie
- Posts: 12
- Joined: Sat Dec 18, 2010 5:11 pm
Re: Help please with PHP...
Imagine you have games on database with code for everyone (embed for example). OK? The game page will show the game which the user clicked and it is stored in the database. Can you please write the code for homepage and for the game page? Please!Jonah Bron wrote:That's right.makisoustas wrote:Do you mean put this on the homepage for example: <a href="http://example.com/game.php?game=somegame">(Here will be placed text or image of the game)</a> and in the game page I will place this: $_GET['game'] ??
If that's where your games are stored, then yes.makisoustas wrote:How the game page will show the game? From the database and with the "echo ()" function??
- Jonah Bron
- DevNet Master
- Posts: 2764
- Joined: Thu Mar 15, 2007 6:28 pm
- Location: Redding, California
Re: Help please with PHP...
The first step is to display all games on the home page. They way to do that is to select all items from your database table, and output them. Here's a tutorial on MySQL.
http://www.w3schools.com/php/php_mysql_intro.asp
Could you tell us your table's schema (what columns it has)?
http://www.w3schools.com/php/php_mysql_intro.asp
Could you tell us your table's schema (what columns it has)?
-
makisoustas
- Forum Newbie
- Posts: 12
- Joined: Sat Dec 18, 2010 5:11 pm
Re: Help please with PHP...
I know to display the games from the database with php in the homepage. The database will be called games the table game and inside this table will be title,category,code,image. What is next?Jonah Bron wrote:The first step is to display all games on the home page. They way to do that is to select all items from your database table, and output them. Here's a tutorial on MySQL.
http://www.w3schools.com/php/php_mysql_intro.asp
Could you tell us your table's schema (what columns it has)?
- Jonah Bron
- DevNet Master
- Posts: 2764
- Joined: Thu Mar 15, 2007 6:28 pm
- Location: Redding, California
Re: Help please with PHP...
Do you know how to make the link properly?
-
makisoustas
- Forum Newbie
- Posts: 12
- Joined: Sat Dec 18, 2010 5:11 pm
Re: Help please with PHP...
Do you mean the <a href></a> ??Jonah Bron wrote:Do you know how to make the link properly?
- Jonah Bron
- DevNet Master
- Posts: 2764
- Joined: Thu Mar 15, 2007 6:28 pm
- Location: Redding, California
Re: Help please with PHP...
Yes. The http://example.com/game.php?game=samegame thing.
-
makisoustas
- Forum Newbie
- Posts: 12
- Joined: Sat Dec 18, 2010 5:11 pm
Re: Help please with PHP...
I know good html but in php I am confused. Continue please to the next step...Jonah Bron wrote:Yes. The http://example.com/game.php?game=samegame thing.
- Jonah Bron
- DevNet Master
- Posts: 2764
- Joined: Thu Mar 15, 2007 6:28 pm
- Location: Redding, California
Re: Help please with PHP...
In your table, you'll also have a column called ID. When you list the games on the home page, echo the link with the ID in the url. Have you read the MySQL tutorial yet?
-
makisoustas
- Forum Newbie
- Posts: 12
- Joined: Sat Dec 18, 2010 5:11 pm
Re: Help please with PHP...
No but also I know to echo the id ok. But what is the code that will show the game that the user clicked? I haven't understand yet, sorry!Jonah Bron wrote:In your table, you'll also have a column called ID. When you list the games on the home page, echo the link with the ID in the url. Have you read the MySQL tutorial yet?
- Jonah Bron
- DevNet Master
- Posts: 2764
- Joined: Thu Mar 15, 2007 6:28 pm
- Location: Redding, California
Re: Help please with PHP...
Okay, on the game.php page, you'll get the ID of the game the user clicked on with $_GET['id']. Then select the row from the database with that ID, and echo the code column. Done!
-
makisoustas
- Forum Newbie
- Posts: 12
- Joined: Sat Dec 18, 2010 5:11 pm
Re: Help please with PHP...
Ok thanks but which row from the database? I'm confused!Jonah Bron wrote:Okay, on the game.php page, you'll get the ID of the game the user clicked on with $_GET['id']. Then select the row from the database with that ID, and echo the code column. Done!