<?php
include("config.php");
?>
<html>
<head>
<title>Puzzle - php</title>
<script language="JavaScript" type="text/javascript" src="puzzle.js"></script>
</head>
<body>
<center>
<h1>
<form name="puzzle" action="" method="POST">
<font size="3"><a href="http://gorbem.hu">gorbem.hu</a> </font>
<input type="submit" name="alap" value="Alap"/>
<u>Puzzle</u>
<input type="submit" name="kever" value="Kever"/>
<font size="3"><a href="http://www.gmsoft.uw.hu">gmsoft.uw.hu</a></font>
</form>
</h1>
<?php
if (( !isset($_POST['alap']) && !isset($_POST['kever']) && !isset($_POST['csere']) ) || ( isset($_POST['alap']) )){
print "<img
src=\"0.JPG\" width=\"492\"
height=\"368\">\n";
}
function onscreen(){
$k = 0;
$ered = mysql_query("SELECT *
FROM Puzzle");
print "<table
border=\"1\" bordercolor=\"white\"
cellpadding=\"0\" cellspacing=\"0\" >\n";
while ($sora = mysql_fetch_object($ered)){
$k++;
if ( ($k==1) || ($k==5) || ($k==9) || ($k==13) ){print "<tr>";}
print "<td><img
src=\"$sora->KNev\" width=\"123\"
height=\"92\"></td>";
if ( ($k==4) || ($k==8) || ($k==12) || ($k==16) ){print "</tr>";}
}
print "</table>";
}
function cserel($a,$b){
$ered = mysql_query("SELECT *
FROM Puzzle WHERE id='$a'");
$sora = mysql_fetch_object($ered); $p = $sora->KNev;
$ered = mysql_query("SELECT *
FROM Puzzle WHERE id='$b'");
$sora = mysql_fetch_object($ered); $q = $sora->KNev;
mysql_query("UPDATE
Puzzle SET KNev='$q' WHERE id='$a'");
mysql_query("UPDATE
Puzzle SET KNev='$p' WHERE id='$b'");
}
function vizsgal(){
$kesz = true;
$ered = mysql_query("SELECT *
FROM Puzzle");
while ($sora = mysql_fetch_object($ered)){
$n = $sora->id;
$n = $n+0;
$knev = $sora->KNev;
$k = substr($knev,0,2)+0;
if ( $n !== $k ){$kesz = false;}
}
return $kesz;
}
if ( isset($_POST['kever']) ){
for ($i=0; $i<100; $i++){
cserel(rand(1,16),rand(1,16));
}
onscreen();
}
if ( isset($_POST['csere']) ){
$a = 0;
$b = 0;
for ($i=1; $i<=16; $i++){
$l = "ch";
$m = $l.$i;
if ( isset($_POST[$m]) ){
if ( $a==0 ){
$a = $i;
}
else $b = $i;
}
}
cserel($a,$b);
if ( vizsgal() ){
print "<img
src=\"0.JPG\" width=\"492\"
height=\"368\">\n";
}
else onscreen();
}
print "<form
name=\"csere\" action=\"\" method=\"POST\"
>\n";
print "<table
border=\"1\" cellpadding=\"0\" cellspacing=\"0\"
>\n";
for ($i=1; $i<=4; $i++){
print "<tr>\n";
for ($j=1; $j<=4; $j++){
print "<td
align=\"center\">"; $k = 4*($i-1)+$j;
print "<input
type=\"checkbox\" name=\"ch$k\" onclick=\"Kuld()\"/></td>\n";
}
print "</tr>\n";
}
print "</table>\n";
print "<input
type=\"hidden\" type=\"submit\" name=\"csere\"
value=\"\"/>\n";
print "</form>\n";
?>
</center>
</body>
</html>
Nincsenek megjegyzések:
Megjegyzés küldése