1. Home
  2. Computing & Technology
  3. PHP / MySQL
photo of Angela Bradley
Angela's PHP / MySQL Blog

By Angela Bradley, About.com Guide to PHP / MySQL

Guess the Number

Monday January 8, 2007
One simple game you can write with PHP is a guess the number game. This allows a user to guess a number between 1-100 (or whatever you set the range to.) The script then tells them if their guess is too high, too low, or if they have won.
Comments
January 27, 2007 at 5:30 am
(1) Steve says:

Good tutorial, but it wouldn’t run on my PHP server, which doesn’t translate posted values straight to variables. I appended this code to the start of my program;

//Get any posted numbers
if($Num=$_POST['Num']);
if($x=$_POST['x']);

The statements are nested inside IF statements, so they don’t pass any errors if no values are posted. The rest of your program works like a charm! Thanks for this great tutorial!

Leave a Comment

Line and paragraph breaks are automatic. Some HTML allowed: <a href="" title="">, <b>, <i>, <strike>

Explore PHP / MySQL
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. PHP / MySQL

©2009 About.com, a part of The New York Times Company.

All rights reserved.