Page 1 of 2

Help please with PHP...

Posted: Sat Dec 18, 2010 5:17 pm
by makisoustas
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!

Re: Help please with PHP...

Posted: Sat Dec 18, 2010 6:10 pm
by Jonah Bron
You can link to the page like this:

Code: Select all

http://example.com/game.php?game=somegame
Then access the value of ?game with $_GET['game']. In this case, the value of $_GET['game'] would be "somegame".

Re: Help please with PHP...

Posted: Sun Dec 19, 2010 4:36 am
by makisoustas
Jonah Bron wrote:You can link to the page like this:

Code: Select all

http://example.com/game.php?game=somegame
Then access the value of ?game with $_GET['game']. In this case, the value of $_GET['game'] would be "somegame".
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??

And thanks for your reply!

Re: Help please with PHP...

Posted: Sun Dec 19, 2010 2:21 pm
by Jonah Bron
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'] ??
That's right.
makisoustas wrote:How the game page will show the game? From the database and with the "echo ()" function??
If that's where your games are stored, then yes.

Re: Help please with PHP...

Posted: Sun Dec 19, 2010 2:26 pm
by makisoustas
Jonah Bron wrote:
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'] ??
That's right.
makisoustas wrote:How the game page will show the game? From the database and with the "echo ()" function??
If that's where your games are stored, then yes.
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!

Re: Help please with PHP...

Posted: Sun Dec 19, 2010 2:46 pm
by Jonah Bron
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)?

Re: Help please with PHP...

Posted: Sun Dec 19, 2010 2:51 pm
by makisoustas
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)?
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?

Re: Help please with PHP...

Posted: Sun Dec 19, 2010 3:36 pm
by Jonah Bron
Do you know how to make the link properly?

Re: Help please with PHP...

Posted: Sun Dec 19, 2010 3:37 pm
by makisoustas
Jonah Bron wrote:Do you know how to make the link properly?
Do you mean the <a href></a> ??

Re: Help please with PHP...

Posted: Sun Dec 19, 2010 3:40 pm
by Jonah Bron
Yes. The http://example.com/game.php?game=samegame thing.

Re: Help please with PHP...

Posted: Sun Dec 19, 2010 3:43 pm
by makisoustas
Jonah Bron wrote:Yes. The http://example.com/game.php?game=samegame thing.
I know good html but in php I am confused. Continue please to the next step...

Re: Help please with PHP...

Posted: Sun Dec 19, 2010 3:45 pm
by Jonah Bron
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?

Re: Help please with PHP...

Posted: Sun Dec 19, 2010 3:51 pm
by makisoustas
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?
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!

Re: Help please with PHP...

Posted: Sun Dec 19, 2010 4:00 pm
by Jonah Bron
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!

Re: Help please with PHP...

Posted: Sun Dec 19, 2010 4:07 pm
by makisoustas
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!
Ok thanks but which row from the database? I'm confused! :P