Hello,
(sorry if my english is bad)
I would like to make a online game like "unanimo":
(rules : I give a image , players give eight words they associate with this image. They score points for each words another player also wrote..see here for more explications about real game : http://cocktailgames.com/en/cocktailgames/produit/unanimo )
(i want that for my forum, for a christmas contest) but i'm a php amateur so is very difficult. Some can help me to finish score.php please ? i find occurence but i don't understand how i can count point for each player ....any idea ?
single answer = 0 point
2 identical answers = 2 points
3 identical answers = 3 points
etc...
This is i have already made:
index
<form action="insert.php" method="post">
Pseudo: <input type="text" name="pseudo" /><br><br>
Mot 1: <input type="text" name="mot1" /><br><br>
Mot 2: <input type="text" name="mot2" /><br><br>
Mot 3: <input type="text" name="mot3" /><br><br>
Mot 4: <input type="text" name="mot4" /><br><br>
Mot 5: <input type="text" name="mot5" /><br><br>
Mot 6: <input type="text" name="mot6" /><br><br>
Mot 7: <input type="text" name="mot7" /><br><br>
Mot 8: <input type="text" name="mot8" /><br><br>
<input type="submit" />
</form>
insert.php
<?php
$con = mysql_connect("xxx","xxx","xxx");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("unanimo", $con);
$sql="INSERT INTO unanimo (pseudo, mot1)
VALUES
('$_POST[pseudo]','$_POST[mot1]'),
('$_POST[pseudo]','$_POST[mot2]'),
('$_POST[pseudo]','$_POST[mot3]'),
('$_POST[pseudo]','$_POST[mot4]'),
('$_POST[pseudo]','$_POST[mot5]'),
('$_POST[pseudo]','$_POST[mot6]'),
('$_POST[pseudo]','$_POST[mot7]'),
('$_POST[pseudo]','$_POST[mot8]')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
else
{
header('Location: http://xxxxxx');
}
mysql_close($con)
?>
score.php
<?php$con = mysql_connect("xxx","xxx","xxx");
mysql_select_db("unanimo");
$req = mysql_query("SELECT mot1, COUNT(*) as nbre FROM unanimo GROUP BY mot1 HAVING ( COUNT(nbre) > 1 ) ORDER BY nbre DESC ")or die(mysql_error());
while ($donnees = mysql_fetch_array($req)) {
echo "<TR><TD>".$donnees['mot1']." </TD><TD>".$donnees['nbre']."</TD></TR>";
}
?>