Having trouble with shuffle code !!!
Posted: Fri Jan 14, 2005 9:46 am
I am working with code to shuffle numbers. I am able to use it for my horizontal (top row) and it works fine.
My problem is getting it to work for the vertical ( red) side row.
The problem is that when I apply this same code to the vertical ---- the numbers inside the square get all messed up -- they have to remain 0 thru 99.
Thanks for your help !!!!
The section of code that applies to this problem is :
My entire code is in http://poolsforfun.com/squares2.php
My problem is getting it to work for the vertical ( red) side row.
The problem is that when I apply this same code to the vertical ---- the numbers inside the square get all messed up -- they have to remain 0 thru 99.
Thanks for your help !!!!
The section of code that applies to this problem is :
Code: Select all
<table border=1 width=800 cellspacing=0 cellpadding=5>
<tr>
<td align=center width="9%" height=25 valign=top><font color=black><b></b></font><br><font color=red><b></b></font></td>
<td width="1%"></td>
<?
// THIS IS WHERE ALL OF THE MAGIC HAPPENS. FIRST WE PRINT OUT THE TOP ROW OF SQUARES...
$randarray=array();
for($k=0; $k<=9; $k++) {
$randarrayї] = $k;
}
shuffle($randarray);
foreach ($randarray as $k) {
echo "\t<td width="9%" height=25 align=center><b>"; if ($mystery) { echo "<name=col$k>?"; } else { echo "$k"; } echo "</b></td>\n";
} ?>
<tr>
<td height=10></td>
</tr>
<?
// NOW THE GRID IS BEING PRINTED
for($i=0; $i<=9; $i++) {
$rownew = "row"."$i";
echo "<tr>\n\t<td align=center><font color=red><b>"; if ($mystery) { echo "<name=$rownew>?"; } else { echo "$i"; } echo "</b></font></td><td width="1%"></td>";
for($j=0; $j<=9; $j++) {
$colnew = "col"."$j";
$both_loop = $rownew.$colnew;
$formatted_selection = $rownew.':'.$colnew;
$number = $i.$j;
$digits = sprintf('%2d', $number);
if (${$rownew.$colnew}) {
$pick = "$rownew:$colnew";
echo "\n\t<td width="9%" align=center>"; if ($mystery) { echo "<font color=red><b><name=$rownew>?</b></font> : <b><name=$colnew>?</b>"; } else { echo "<b>$digits</b>"; } echo "<br><font size=1><b>$name</b></font></td>";
} // endwhile
else {
echo "\n\t<td width="9%" align=center>"; if ($mystery) { echo "<font color=red><b><name=$rownew>?</b></font> : <b><name=$colnew>?</b>"; } else { echo "<b>$digits</b>"; } echo "<br><input type=radio name="selection" value="$rownew:$colnew""; if ($selection == $formatted_selection) echo " checked"; echo "></td>";
}
} //for($j=0; $j<=9; $j++) {
echo "\n</tr>\n";
} //for($i=0; $i<=9; $i++) {
?>
</table>
<br>
<? if ($squares_add) { ?>
<input class=button type="submit" value="Submit" name="submit">
<input class=button type="reset" value = "Clear">
<? } ?>
<br><br><a href="http://<?=$website?>">Return to <?=$website?></a>
</center>
</body>
</html>