#native_company# #native_desc#
#native_cta#

Su doku generator

By susan van wyk
on March 21, 2008

Version: 1

Type: Sample Code (HOWTO)

Category: Games

License: GNU General Public License

Description: Generates an unlimited number of random su doku’s you will need a mysql database, and will need to write your own html table to hold the game, see it in action
http:apps.facebook.com/playbynumber

Written by Susan Van Wyk
email me at [email protected] if you have any trouble using this script
Use it for anything you like
but email me to let me know enjoy
Create database sudo
id auto increment
81 VARCHAR(10) fields
you must construct your own html table for the game
<a href='http://www.xcapetosouthafrica.co.za/games8'>See the game in action</a>
<a href='http://apps.facebook.com/playbynumber'>See the game in action</a>
<a href='http://2site.myhosting.com/playbynumber'>See the game in action</a>
<?php

$array = array("1" , "2" , "3" , "4" , "5" , "6" , "7" , "8" , "9");
shuffle($array);
foreach ($array as $ar) 
{ 
echo "$ar"; 
} 
echo "<br />";
$one[0] ="$array[5]";
$one[1] ="$array[4]";
$one[2] ="$array[3]";
$one[3] ="$array[8]";
$one[4] ="$array[6]";
$one[5] ="$array[7]";
$one[6] ="$array[2]";
$one[7] ="$array[1]";
$one[8] ="$array[0]";
foreach ($one as $on) 
{ 
echo "$on"; 
} 
echo "<br />";
$two[0] ="$one[4]";
$two[1] ="$one[5]";
$two[2] ="$one[3]";
$two[3] ="$one[8]";
$two[4] ="$one[7]";
$two[5] ="$one[6]";
$two[6] ="$one[2]";
$two[7] ="$one[1]";
$two[8] ="$one[0]";
foreach ($two as $to) 
{ 
echo "$to"; 
} 
echo "<br />";
$three[0] ="$two[1]";
$three[1] ="$two[3]";
$three[2] ="$two[4]";
$three[3] ="$two[5]";
$three[4] ="$two[6]";
$three[5] ="$two[7]";
$three[6] ="$two[8]";
$three[7] ="$two[2]";
$three[8] ="$two[0]";
foreach ($three as $th) 
{ 
echo "$th"; 
} 
echo "<br />";
$four[0] ="$three[5]";
$four[1] ="$three[4]";
$four[2] ="$three[6]";
$four[3] ="$three[0]";
$four[4] ="$three[7]";
$four[5] ="$three[8]";
$four[6] ="$three[1]";
$four[7] ="$three[3]";
$four[8] ="$three[2]";
foreach ($four as $fo) 
{ 
echo "$fo"; 
} 
echo "<br />";
$five[0] ="$four[7]";
$five[1] ="$four[4]";
$five[2] ="$four[5]";
$five[3] ="$four[2]";
$five[4] ="$four[6]";
$five[5] ="$four[8]";
$five[6] ="$four[3]";
$five[7] ="$four[1]";
$five[8] ="$four[0]";
foreach ($five as $fi) 
{ 
echo "$fi"; 
} 
echo "<br />";
$six[0] ="$five[7]";
$six[1] ="$five[3]";
$six[2] ="$five[8]";
$six[3] ="$five[5]";
$six[4] ="$five[0]";
$six[5] ="$five[4]";
$six[6] ="$five[1]";
$six[7] ="$five[2]";
$six[8] ="$five[6]";
foreach ($six as $si) 
{ 
echo "$si"; 
} 
echo "<br />";
$sev[0] ="$six[3]";
$sev[1] ="$six[4]";
$sev[2] ="$six[5]";
$sev[3] ="$six[7]";
$sev[4] ="$six[8]";
$sev[5] ="$six[6]";
$sev[6]="$six[2]";
$sev[7] ="$six[1]";
$sev[8] ="$six[0]";
foreach ($sev as $se) 
{ 
echo "$se"; 
} 
echo "<br />";
$eig[0] ="$sev[5]";
$eig[1] ="$sev[3]";
$eig[2] ="$sev[4]";
$eig[3] ="$sev[6]";
$eig[4] ="$sev[7]";
$eig[5] ="$sev[8]";
$eig[6] ="$sev[0]";
$eig[7] ="$sev[2]";
$eig[8] ="$sev[1]";
foreach ($eig as $ei) 
{ 
echo "$ei"; 
} 
include "config.php";
$var1 ="$array[0]";
$var2 ="$array[1]";
$var3 ="$array[2]";
$var4 ="$array[3]";
$var5 ="$array[4]";
$var6 ="$array[5]";
$var7 ="$array[6]";
$var8 ="$array[7]";
$var9 ="$array[8]";
$var10 ="$one[0]";
$var11 ="$one[1]";
$var12 ="$one[2]";
$var13 ="$one[3]";
$var14 ="$one[4]";
$var15 ="$one[5]";
$var16 ="$one[6]";
$var17 ="$one[7]";
$var18 ="$one[8]";


$var19 ="$two[0]";
$var20 ="$two[1]";
$var21 ="$two[2]";
$var22 ="$two[3]";
$var23 ="$two[4]";
$var24 ="$two[5]";
$var25 ="$two[6]";
$var26 ="$two[7]";
$var27 ="$two[8]";


$var28 ="$three[0]";
$var29 ="$three[1]";
$var30 ="$three[2]";
$var31 ="$three[3]";
$var32 ="$three[4]";
$var33 ="$three[5]";
$var34 ="$three[6]";
$var35 ="$three[7]";
$var36 ="$three[8]";


$var37 ="$four[0]";
$var38 ="$four[1]";
$var39 ="$four[2]";
$var40 ="$four[3]";
$var41 ="$four[4]";
$var42 ="$four[5]";
$var43 ="$four[6]";
$var44 ="$four[7]";
$var45 ="$four[8]";


$var46 ="$five[0]";
$var47 ="$five[1]";
$var48 ="$five[2]";
$var49 ="$five[3]";
$var50 ="$five[4]";
$var51 ="$five[5]";
$var52 ="$five[6]";
$var53 ="$five[7]";
$var54 ="$five[8]";


$var55 ="$six[0]";
$var56 ="$six[1]";
$var57 ="$six[2]";
$var58 ="$six[3]";
$var59 ="$six[4]";
$var60 ="$six[5]";
$var61 ="$six[6]";
$var62 ="$six[7]";
$var63 ="$six[8]";


$var64 ="$sev[0]";
$var65 ="$sev[1]";
$var66 ="$sev[2]";
$var67 ="$sev[3]";
$var68 ="$sev[4]";
$var69 ="$sev[5]";
$var70 ="$sev[6]";
$var71 ="$sev[7]";
$var72 ="$sev[8]";


$var73 ="$eig[0]";
$var74 ="$eig[1]";
$var75 ="$eig[2]";
$var76 ="$eig[3]";
$var77 ="$eig[4]";
$var78 ="$eig[5]";
$var79 ="$eig[6]";
$var80 ="$eig[7]";
$var81 ="$eig[8]";

$qu = mysql_query("SELECT timestamp FROM sudo ORDER BY id DESC LIMIT 1");
while ($ro = mysql_fetch_object($qu) ) 
{ 
$ti = $ro->timestamp;
echo "oldtime $ti<br />";
$tim = explode('-', $ti);
$new = mktime(0, 0, 0, $tim['1'], $tim['2'], $tim['0']);
echo "MKnew $new<br />";
$newtime = $new + 86400;
echo "newtime $newtime<br />"; 

$time = date("Y-m-d", $newtime);
echo "New time $time<br />"; 
}  
$q = "INSERT INTO sudo(var1, var2, var3, var4, var5, var6, var7, var8, var9, var10, var11, var12, var13, var14, var15, var16, var17, var18, var19, var20, var21, var22, var23, var24, var25, var26, var27, var28, var29, var30, var31, var32, var33, var34, var35, var36, var37, var38, var39, var40, var41, var42, var43, var44, var45, var46, var47, var48, var49, var50, var51, var52, var53, var54, var55, var56, var57, var58, var59, var60, var61, var62, var63, var64, var65, var66, var67, var68, var69, var70, var71, var72, var73, var74, var75, var76, var77, var78, var79, var80, var81, timestamp) VALUES ('$var1', '$var2', '$var3', '$var4', '$var5', '$var6', '$var7', '$var8', '$var9', '$var10', '$var11', '$var12', '$var13', '$var14', '$var15', '$var16', '$var17', '$var18', '$var19', '$var20', '$var21', '$var22', '$var23', '$var24', '$var25', '$var26', '$var27', '$var28', '$var29', '$var30', '$var31', '$var32', '$var33', '$var34', '$var35', '$var36', '$var37', '$var38', '$var39', '$var40', '$var41', '$var42', '$var43', '$var44', '$var45', '$var46', '$var47', '$var48', '$var49', '$var50', '$var51', '$var52', '$var53', '$var54', '$var55', '$var56', '$var57', '$var58', '$var59', '$var60', '$var61', '$var62', '$var63', '$var64', '$var65', '$var66', '$var67', '$var68', '$var69', '$var70', '$var71', '$var72', '$var73', '$var74', '$var75', '$var76', '$var77', '$var78', '$var79', '$var80', '$var81', '$time')";
$result = mysql_query($q)
or die ("ERROR IN QUERY: $q . " . mysql_error());
echo "New sudoku added";
?>