$hd = mysql_connect("sql-server.k8s-kh5ts6lm", "jeux9wu_Sabine", "nathsab0") or die ("Connection refusˇe");
$wpdb=mysql_select_db ("jeux9wu_espagnol", $hd) or die ("Cette base n'existe pas");
//$Table="mots5";
$Table1="entrainei";
$livre=$_POST["livre"];
$lecon=$_POST["lecon"];
$joueur=$_POST["joueur"];
$languei=$_POST["languei"];
$languef=$_POST["languef"];
//$Table=$_POST['Table'];
$Table="entraine1i";
$ida=$_POST["ida"];
$id1a=$_POST["id1a"];
function echappement ($data)
{global $bd;
if(ini_get('magic_quotes_gpc'))
{$data=stripslashes($data);
}
return mysql_escape_string($data);
}
$query="SELECT * FROM $Table1 WHERE idconnect='1'";
$res=MYSQL_QUERY("$query",$hd);
$ligne1=mysql_fetch_row($res);
//echo 'ligne1 ',$ligne1[0],' ',$ligne1[1],'
';
if($ligne1[1]==-1){
$id=0;
$id1=0;
$nmont=1;
$date = DATE("d/M/Y H:i:s");//Temps conventionnel Date
$heuref = DATE("H:i:s"); //Temps conventionnel Heure
$heurei = DATE("H:i:s"); //Temps conventionnel Heure
$timei = TIME(); //Temps Unix
$choix=$_POST['choix'];
//$choix='A';
//echo 'choix: ',$choix, ' livre: ',$livre, ' lecon: ',$lecon;
if($lecon!= "tout") $query="SELECT * FROM $Table WHERE (lecon='$lecon') ";
else $query="SELECT * FROM $Table ";
$res=MYSQL_QUERY("$query",$hd);
$j=-1;
while( $ligne=mysql_fetch_row($res))
{
//echo"";
$j++;
if($choix=='A'){
$languei="espagnol";
$languef="francais";
$listea[$j]=$ligne[1];
$input[$j]=echappement ($ligne[2]);
}
else{
$languei="francais";
$languef="espagnol";
$listea[$j]=echappement ($ligne[2]);
$input[$j]=$ligne[1];
}
//echo "$ligne[0] | ";
//echo "$ligne[1] | ";
//echo "$ligne[2] | ";
//echo "$ligne[3] | ";
//echo "$ligne[10] | ";
//echo"
";
}
//echo"";
$j++;
//echo 'j: ',$j,'
';
$numbers = range(0, $j-1);
shuffle($numbers);
$i=0;
foreach ($numbers as $number) {
//echo "$number ";
$rand_keys[$i] =$number;
$i++;
}
//$rand_keys = array_rand($input, $j);
for ($i=0; $i<$j;$i++){
$listef[$i]= $input[$rand_keys[$i]];
$mota= $listea[$i];
$motf= $input[$i];
$motr= $input[$rand_keys[$i]];
//echo '$i: ',$i, 'rand: ',$rand_keys[$i],'mota: ',$mota,' , ',$motf,' , ',$motr,'
';
if($i==0)
$query="update $Table1 set nmont='$nmont', mota='$mota', motf='$motf',
motr='$motr' WHERE idConnect = '1'";
else
$query="INSERT INTO $Table1
VALUES ('','$nmont','$mota','$motf','$motr','$date','$heurei','$heuref','$note')";
$sql_result=MYSQL_QUERY("$query",$hd);
}
}
else{
//echo "nmont=1";
$query="SELECT * FROM $Table1";
$res=MYSQL_QUERY("$query",$hd);
$num = MYSQL_NUM_ROWS($res);
$j=0;
while( $ligne2=mysql_fetch_row($res))
{
//echo"";
$listea[$j]=$ligne2[2];
$input[$j]=$ligne2[3];
$listef[$j]=$ligne2[4];
//echo "$j | ";
//echo "$listea[$j] | ";
//echo "$input[$j] | ";
//echo "$listef[$j] | ";
$j++;
//echo"
";
}
}
if(!empty($_POST["mon_champ"])){
$id = $_POST["id"];
$id++;
$id1 = $_POST["id1"];
$fichier=$_POST["mon_champ"];
$choixa=echappement ($_POST["mon_champf"]);
$choixe=' ';
for ($i=0; $i<$j+1; $i++){
//echo "i: ",$i," listea: ",$listea[$i]," echap: ",echappement ($listea[$i])," fichier: ",$fichier,' echap: ',echappement ($fichier)," choixe: ",$choixe, " echap: ",echappement ($choixe),'
';
if(echappement ($listea[$i])==$fichier || echappement ($listea[$i]).' '==$fichier || echappement ($listea[$i])==$fichier.' ') {
$choixe=echappement ($input[$i]);
echo '
';
$na=strlen($choixa);
$ne=strlen($choixe);
$choixa1=$choixa.' ';
$na1=strlen($choixa1);
//echo "choixa: ",$choixa,' , ',$na,' , ',$na1," choixe: ",$choixe,' , ',$ne, " echap: ",echappement ($choixe),'
';
if($choixa==$choixe || $choixa==$choixe.' ' || $choixa1==$choixe) {
$mota=' *'.$fichier.' * '.$choixa.'*';
$listea[$i]=$mota;
//echo "i: ",$i,' mota: ',$mota,' u1: ',$mota[0],' u2: ',$mota[1],'
';
$idconnect=$i+1;
$query="update $Table1 set mota='$mota' WHERE idConnect = '$idconnect'";
$sql_result=MYSQL_QUERY("$query",$hd);
$motr=' *'.$choixa.'*';
for ($i1=0; $i1<$j+1; $i1++){
//echo "i1: ",$i1,' choixa: ',$choixa,'listef: ',$listef[$i1],'
';
if(echappement ($listef[$i1])==echappement ($choixa) || echappement ($listef[$i1])==echappement ($choixa1)) {
//echo "i1: ",$i1,' motr: ',$motr,'
';
$listef[$i1]=$motr;
$idconnect=$i1+1;
$query="update $Table1 set motr='$motr' WHERE idConnect = '$idconnect'";
$sql_result=MYSQL_QUERY("$query",$hd);
}
}
}
}
}
if($choixa==$choixe || $choixa==$choixe.' ' || $choixa1==$choixe) {
$id1++;
echo 'Tu as dit que le mot ', $languei,' ',$fichier,' correspond au mot ',$languef,' ',$choixa,'
TB
';
}
else{
if($choixe!=' ')
echo 'Tu as dit que le mot ', $languei,' ',$fichier,' correspond au mot ', $languef,' ',$choixa,'
Non, le vrai mot est ',$choixe,'
';
else
echo "tu as déjà gagné cette question
";
}
$ida=$id;
$id1a=$id1;
echo "nombre de réponses justes ",$id1," nombre de questions ",$id,'
';
if($id1==$num && $id1!=0) {echo 'Il t\'a fallu ',$id,' questions pour avoir tes ',$id1,' réponses justes
';}
}else{
echo "n'oublie pas d'appuyer sur les deux lignes";
$id=$ida;
$id1=$id1a;
//echo "id: ",$id," id1: ",$id1," else
";
}
?>
Clique d'abord sur le mot ou la phrase de gauche, PUIS sur le mot ou la phrase de droite qui a le même sens
$mapage=$_SERVER['PHP_SELF'];
if($languei=="espagnol") $languei="esp-fran";
else $languei="fran-esp";
$query="SELECT * FROM $Table1 WHERE idconnect='1'";
$res=MYSQL_QUERY("$query",$hd);
$ligne1=mysql_fetch_row($res);
$date=$ligne1[5];
$suivant="penttextei.php?page=$mapage&id=$id&id1=$id1&lecon=$lecon&Table=$Table&languei=$languei&date=$date&prog=plani.html&joueur=$joueur";//echo "suivant: ",$suivant;
$suivant1="penttextei.php?page=$mapage&id=$id&id1=$id1&lecon=$lecon&Table=$Table&languei=$languei&date=$date&prog=entmotsi.php&joueur=$joueur";
?>
Pour recommencer
Pour retourner à plan