Please help!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
rkinfoarch
Forum Newbie
Posts: 4
Joined: Fri Oct 10, 2008 4:04 am

Please help!

Post by rkinfoarch »

Hi all,

First of all I know nothing about PHP.

I'm looking to develop a webpage with a simple timed word game( 2minutes). Which is explained below.

Start button starts the game.

1) the page will display a question.
Example:- Question1. ATM

2) Player will enter the answer in the Text box

Example:- Answer1. Automatic Teller Machine.

3) Player will click the Next Button.
4) Question2 will be displayed.
5) After 15 questions a Submit button will be displayed and the player will enter the Answer 15 and clicks the Submit button.
6) The game will be stopped if 2 mins is over before Question15.

6) NOW after Submit button is clicked, the game programme should save the result(answers and time) in to the DB along with the user ID.

* Questions will be available in the DB (200+ Questions).
* The code should randomly pick the 15 questions from the DB and display in the game one after another.

Please someone help me in developing this. I dont even know if this is possible in PHP.

Thank a million in advance.
Rk
User avatar
papa
Forum Regular
Posts: 958
Joined: Wed Aug 27, 2008 3:36 am
Location: Sweden/Sthlm

Re: Please help!

Post by papa »

No probs doing it in PHP. But no one here will write the code for you.

Start programming and show us your progress and we'll give you input.
rkinfoarch
Forum Newbie
Posts: 4
Joined: Fri Oct 10, 2008 4:04 am

Re: Please help!

Post by rkinfoarch »

Thanks alot for telling me that its possible to do it in PHP.

But about programming by myself, I cant becoz as I said I know nothing about it. I'll wait for someone who can tell me how to start atleast.

Thanks again.
RK.
User avatar
papa
Forum Regular
Posts: 958
Joined: Wed Aug 27, 2008 3:36 am
Location: Sweden/Sthlm

Re: Please help!

Post by papa »

Well first of all I would suggest you to buy a book about PHP which is an easy way to get started.

Download a program called Wamp and start reading on php.net.

If you know nothing about PHP it might not be the easiest game to start with however.
rkinfoarch
Forum Newbie
Posts: 4
Joined: Fri Oct 10, 2008 4:04 am

Re: Please help!

Post by rkinfoarch »

Started Downloading Wamp Server 2!

But if someone can really help me with the initial code, It would be of a really great help.

Thanks a million in advance.
RK
User avatar
papa
Forum Regular
Posts: 958
Joined: Wed Aug 27, 2008 3:36 am
Location: Sweden/Sthlm

Re: Please help!

Post by papa »

Well first of all you need to figure out what kind of structure you need for this project.

You want a button to start the game right. So start off by creating a form for that, that will either take you to a new page or just pass a var to itself:

Code: Select all

<?php
include_once("./questions.php");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 
<html>
<head>
    <title>2 Minutes</title>
</head>
 
<body>
<?php
switch($_POST['action']) {
    default:
?>
<FIELDSET>
<LEGEND>2 Minutes</LEGEND>
<form method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>">
<input type="hidden" name="action" value="play" />
<input type="submit" value="Start Game" />
</form>
</FIELDSET>
<?php
    break;
    case "play":
    ?>
<FIELDSET>
<LEGEND>2 Minutes</LEGEND>
<form method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>">
<input type="hidden" name="start_time" value="<?php echo $start_time; ?>" />
<input type="hidden" name="questions[]" value="<?php echo $questions; ?>" />
<input type="text" name="question" value="" size=20 />
<input type="submit" value="Answer" />
<br />
Time left: 2:00
</form>
</FIELDSET>
<?php
    break;
}
?>
 
</body>
</html>
Before we start with the mysql part of it, it's easy just to hard code a couple of questions.

Just an example of a page where you store important variables etc:

Code: Select all

 
<?php
 
//questions.php
 
define("TIME_LIMIT", 240);
 
$questions = array(
"How many strings have a guitar?", 
"Name of Metallica's singer?",
"What is Overkill's singer called?",
"Drummer in Metallica?",
"Is reverb and delay the same thing?"
);
 
$answers = array(
6,
"James Hetfield",
"Blitz",
"Lars Ulrich",
"No"
);
 
?>
So now we got 5 questions and 2 forms.

The first function we need to create is "display random questions" and then "see if not question is already answered".

After that you need to look through the answer array and see if the correct answer is provided or not. When the basic functionality is done you can start implementing the time stuff.
rkinfoarch
Forum Newbie
Posts: 4
Joined: Fri Oct 10, 2008 4:04 am

Re: Please help!

Post by rkinfoarch »

Thanks alot my dear friend,

I've save the two codes, the first one as questions.html and second one as questions.php. when Start Game button is clicked the page says "page cannot be displayed".

Do i have to put these files in a web server??
I already have installed Wamp Server2.

your quick responses are inspiring me to learn PHP and I've decided to give it a try.

Thank you.
User avatar
papa
Forum Regular
Posts: 958
Joined: Wed Aug 27, 2008 3:36 am
Location: Sweden/Sthlm

Re: Please help!

Post by papa »

You need to put the files in the webserver directory and then write "localhost" in your browser address window.
Post Reply