<?php
require("verification.php");
require("connect.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<link href="style.css" rel="stylesheet" type="text/css" />
<style type="text/css">
.style4 {
font-size: 24px;
color: #fe5800;
font-weight: bold;
}
#apDiv1 {
position:absolute;
left:267px;
top:352px;
width:118px;
height:79px;
z-index:1;
}
.style10 {font-size: 12px; font-weight: bold; }
.style8 {font-size: 12px}
</style>
</head>
<?php
//$row=array();
//$row["word"]=array();
$query = "SELECT * from word ";
$result = mysql_query($query);
$num = mysql_num_rows($result);
if ($num > 0) {
$id_array = array();
while ($row = mysql_fetch_array($result)) {
$id_array []=$row['wordid'];
}
$query = "SELECT * FROM word WHERE wordid=".$id_array[rand(0, (count($id_array)-1))];
$result = mysql_query($query);
$row = mysql_fetch_array($result);
$word = $row['word'];
//array_push($row["wordid"], $row["word"]);
}
?>
<!--<form name="game2">
<input type="text" name="preguess" value="<?php echo $word; ?>">
</form>-->
<SCRIPT LANGUAGE="JavaScript"><!--
gallows = new Array("--------\n| |\n|\n|\n|\n|\n=====",
"--------\n| O\n|\n|\n|\n|\n=====",
"--------\n| O\n| |\n|\n|\n|\n=====",
"--------\n| O\n| \\|\n|\n|\n|\n=====",
"--------\n| O\n| \\|/\n|\n|\n|\n=====",
"--------\n| O\n| \\|/\n| |\n|\n|\n=====",
"--------\n| O\n| \\|/\n| |\n| /\n|\n=====",
"--------\n| O\n| \\|/\n| |\n| / \\\n|\n=====")
//preguess = document.getElementById("txtHint").innerHTML=preguess;
var guessChoices = new Array()
<?php
for ($i=0; $i< count(strlen($row['word'])); $i++) {
echo 'guessChoices['.$i.']= "'. $row['word'][$i] .'";';
}
?>
//guessChoices = new array (guessChoices1)
function startAgain() {
guesses = 0
max = gallows.length-1
guessed = " "
len = guessChoices.length - 1
toGuess = guessChoices[Math.round(len*Math.random())].toUpperCase()
displayHangman()
displayToGuess()
displayGuessed()
}
function stayAway() {
document.game.elements[3].focus()
alert("Don't mess with this form element!")
}
function displayHangman() {
document.game.status.value=gallows[guesses]
}
function displayToGuess() {
pattern=""
for(i=0;i<toGuess.length;++i) {
if(guessed.indexOf(toGuess.charAt(i)) != -1)
pattern += (toGuess.charAt(i)+" ")
else pattern += "_ _"
}
document.game.toGuess.value=pattern
}
function displayGuessed() {
document.game.guessed.value=guessed
}
function badGuess(s) {
if(toGuess.indexOf(s) == -1) return true
return false
}
function winner() {
for(i=0;i<toGuess.length;++i) {
if(guessed.indexOf(toGuess.charAt(i)) == -1) return false
}
return true
}
function guess(s){
if(guessed.indexOf(s) == -1) guessed = s + guessed
if(badGuess(s)) ++guesses
displayHangman()
displayToGuess()
displayGuessed()
if(guesses >= max){
alert("You're dead. The word you missed was "+toGuess+".")
startAgain()
}
if(winner()) {
alert("You won!")
startAgain()
}
}
// --></SCRIPT>
</HEAD>
<BODY>
<div id="container">
<div id="header">
<div class="style4" id="logo">GAME</div>
<div id="menu">
<ul>
<li><a href="userhome.php">home</a></li>
<li><a href="usergame.php" class="active">game</a></li>
<li><a href="how to play.php">how to play</a></li>
<li><a href="highscore.php">high scores</a></li>
<li><a href="logout.php">LOGOUT</a></li>
</ul>
</div>
</div>
<div id="main">
<div id="content">
<div id="head_image">
<div id="slogan">interactive Educational WORD GAME<br />
</div>
<div id="under_slogan_text">
<p class="style8">You have to learn the rules of the game. </p>
<p class="style8"> And then you have to play better than anyone else.</p>
<blockquote>
<blockquote>
<blockquote>
<blockquote>
<blockquote>
<p class="style10">- Albert Einstein</p>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</div>
</div>
<div id="text"><center>
</center>
<h1> <FORM NAME="game">
<PRE>
<TEXTAREA NAME="status" ROWS="7" COLS="16"
ONFOCUS="stayAway()"></TEXTAREA>
<input type="text" name="hiddenField" id="hiddenField" value= "<?php echo $row['word'] ;?>" onfocus="stayAway()" />
</PRE><P>
<textarea NAME="hint" rows = "6" cols = "25"
ONFOCUS="stayAway()"><?php echo $row['meaning'] ;?> </textarea>Hint
<P><BR>
<input type="TEXT" name="toGuess" value= "<?php echo $row['word'] ;?>"
onclick="stayAway()">
Word to guess
<P><BR>
<input type="TEXT" name="guessed"
onfocus="stayAway()" />
Letters guessed so far<BR>
<P> </P>
<INPUT TYPE="BUTTON" VALUE=" A " ONCLICK="guess('A')">
<INPUT TYPE="BUTTON" VALUE=" B " ONCLICK="guess('B')">
<INPUT TYPE="BUTTON" VALUE=" C " ONCLICK="guess('C')">
<INPUT TYPE="BUTTON" VALUE=" D " ONCLICK="guess('D')">
<INPUT TYPE="BUTTON" VALUE=" E " ONCLICK="guess('E')">
<INPUT TYPE="BUTTON" VALUE=" F " ONCLICK="guess('F')">
<INPUT TYPE="BUTTON" VALUE=" G " ONCLICK="guess('G')">
<INPUT TYPE="BUTTON" VALUE=" H " ONCLICK="guess('H')">
<INPUT TYPE="BUTTON" VALUE=" I " ONCLICK="guess('I')">
<INPUT TYPE="BUTTON" VALUE=" J " ONCLICK="guess('J')">
<INPUT TYPE="BUTTON" VALUE=" K " ONCLICK="guess('K')">
<INPUT TYPE="BUTTON" VALUE=" L " ONCLICK="guess('L')">
<INPUT TYPE="BUTTON" VALUE=" M " ONCLICK="guess('M')">
<INPUT TYPE="BUTTON" VALUE=" N " ONCLICK="guess('N')">
<INPUT TYPE="BUTTON" VALUE=" O " ONCLICK="guess('O')">
<INPUT TYPE="BUTTON" VALUE=" P " ONCLICK="guess('P')">
<INPUT TYPE="BUTTON" VALUE=" Q " ONCLICK="guess('Q')">
<INPUT TYPE="BUTTON" VALUE=" R " ONCLICK="guess('R')">
<INPUT TYPE="BUTTON" VALUE=" S " ONCLICK="guess('S')">
<INPUT TYPE="BUTTON" VALUE=" T " ONCLICK="guess('T')">
<INPUT TYPE="BUTTON" VALUE=" U " ONCLICK="guess('U')">
<INPUT TYPE="BUTTON" VALUE=" V " ONCLICK="guess('V')">
<INPUT TYPE="BUTTON" VALUE=" W " ONCLICK="guess('W')">
<INPUT TYPE="BUTTON" VALUE=" X " ONCLICK="guess('X')">
<INPUT TYPE="BUTTON" VALUE=" Y " ONCLICK="guess('Y')">
<INPUT TYPE="BUTTON" VALUE=" Z " ONCLICK="guess('Z')"><P>
<form action="">
<INPUT TYPE="BUTTON" NAME=" restart" VALUE="---- Start Again ----" onclick="startAgain()" >
</form>
<SCRIPT LANGUAGE="JavaScript"><!--
startAgain()
// --></SCRIPT>
</FORM>
</h1>
</div>
</div>
</div><div id="footer">
<div id="left_footer">© Copyright 2011 Ccg design
</div>
<div id="right_footer">
Design by galz & aiza</div>
</div>
</div>
</body>
</html>
galz1452 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.