You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
134 lines
2.4 KiB
134 lines
2.4 KiB
<link rel="stylesheet" href="css.css">
|
|
<meta charset="UTF-8">
|
|
<h1>Morpion</h1>
|
|
<p>
|
|
<form method="post">
|
|
<input type="text" name="forme" required="required" placeholder="Mettre X ou O" maxlength="1">
|
|
<input type="number" name="case" required="required" placeholder="Emplacement (1-9)" maxlength="1">
|
|
<button type="submit">Inserer</button>
|
|
</form>
|
|
</p>
|
|
<?php
|
|
class MyDB extends SQLite3
|
|
{
|
|
function __construct()
|
|
{
|
|
$this->open('mysqlitedb.db');
|
|
}
|
|
}
|
|
|
|
$db = new MyDB();
|
|
|
|
|
|
$colonne="";
|
|
|
|
if(isset($_POST['case'])){
|
|
|
|
if($_POST['case']=='1'){
|
|
$colonne='un';
|
|
}
|
|
elseif ($_POST['case']=='2'){
|
|
$colonne='deux';
|
|
}
|
|
elseif ($_POST['case']=='3'){
|
|
$colonne='trois';
|
|
}
|
|
elseif ($_POST['case']=='4'){
|
|
$colonne='quatre';
|
|
}
|
|
elseif ($_POST['case']=='5'){
|
|
$colonne='cinq';
|
|
}
|
|
elseif ($_POST['case']=='6'){
|
|
$colonne='six';
|
|
}
|
|
elseif ($_POST['case']=='7'){
|
|
$colonne='sept';
|
|
}
|
|
elseif ($_POST['case']=='8'){
|
|
$colonne='huit';
|
|
}
|
|
elseif ($_POST['case']=='9'){
|
|
$colonne='neuf';
|
|
}
|
|
else{
|
|
$colonne='null';
|
|
}
|
|
}
|
|
$valeur="";
|
|
if(isset($_POST['forme'])){
|
|
$valeur=$_POST['forme'];
|
|
}
|
|
|
|
|
|
header("refresh: 2");
|
|
//$db->exec('CREATE TABLE partie(Id STRING,un STRING,deux STRING,trois STRING, quatre STRING,cinq STRING,six STRING,sept STRING,huit STRING,neuf STRING)');
|
|
|
|
|
|
|
|
|
|
$idpartie = "BQANQsS";
|
|
|
|
|
|
|
|
if(isset($colonne)and $valeur!="" and $colonne!=''){
|
|
|
|
$aff=$db->query('SELECT "'.$colonne.'" FROM partie where Id="'.$idpartie.'" ');
|
|
$res = $aff->fetchArray();
|
|
|
|
if(strlen($res[$colonne])==1){
|
|
echo " <p> Insertion impossible une valeur est déjà à l'intérieur</p> <br>";
|
|
}
|
|
else{
|
|
$update = $db->query('UPDATE partie SET "'.$colonne.'" = "'.$valeur.'" where Id="'.$idpartie.'" ');
|
|
}
|
|
|
|
}
|
|
|
|
//$db->query('INSERT INTO partie(Id) VALUES("'.$idpartie.'")');
|
|
|
|
//$db->query('INSERT INTO partie(Id) VALUES("'.$idpartie.'")');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$afficher = $db->query('SELECT * FROM partie where Id="'.$idpartie.'" ');
|
|
while ($row = $afficher->fetchArray()) {
|
|
|
|
$un=$row['un'];
|
|
$deux=$row['deux'];
|
|
$trois=$row['trois'];
|
|
$quatre=$row['quatre'];
|
|
$cinq=$row['cinq'];
|
|
$six=$row['six'];
|
|
$sept=$row['sept'];
|
|
$huit=$row['huit'];
|
|
$neuf=$row['neuf'];
|
|
|
|
|
|
}
|
|
echo "
|
|
<table>
|
|
<tr>
|
|
<td>$un</td>
|
|
<td>$deux</td>
|
|
<td>$trois</td>
|
|
</tr>
|
|
<tr>
|
|
<td>$quatre</td>
|
|
<td>$cinq</td>
|
|
<td>$six</td>
|
|
</tr>
|
|
<tr>
|
|
<td>$sept</td>
|
|
<td>$huit</td>
|
|
<td>$neuf</td>
|
|
</tr>
|
|
</table>
|
|
";
|
|
|
|
?>
|