Source of “minesweeper.php”.
46 lines, 1.9 KBytes.   Last modified 6:32 pm, 3rd May 2016 PDT.
1 <?php // Emacs settings: -*- mode: Fundamental; tab-width: 4; -*- 2 3 //////////////////////////////////////////////////////////////////////////// 4 // // 5 // Minesweeper, implemented in JavaScript // 6 // // 7 // Copyright 1998-2007, Andrew D. Birrell // 8 // // 9 // PHP to generate the playing area HTML // 10 // // 11 // Usage: // 12 // $cols = 8; // 13 // $rows = 8; // 14 // require("minesweeper.php"); // 15 // // 16 //////////////////////////////////////////////////////////////////////////// 17 18 if (!isset($cols) || !isset($rows)) { 19 exit("Minesweeper.php: missing parameter(s)"); 20 } 21 22 ?> 23 <!-- The following HTML is generated by a script. See ./source.php --> 24 <TABLE ID=sqTable onmouseup="return false"> 25 <TR><TD CLASS=score COLSPAN=<?php echo $cols?>> 26 <DIV CLASS=counter ID=mines>&nbsp;</DIV> 27 <DIV CLASS=counter ID=timer>&nbsp;</DIV> 28 <IMG ID=smiley SRC="erasing.gif" ALT="" 29 onmousedown="return clickSmiley(event)"> 30 </TD></TR> 31 <?php 32 for ($row = 0; $row < $rows; $row++) { ?> 33 <TR> 34 <?php 35 for ($col = 0; $col < $cols; $col++) { ?> 36 <TD CLASS=sq ID="sq-<?php echo $row * $cols + $col ?>" 37 onmousedown="return clickSq(event,<?php echo $row * $cols + $col ?>)" 38 >&nbsp;</TD> 39 <?php 40 } ?> 41 </TR> 42 <?php 43 } 44 ?> 45 </TABLE> 46 <!-- End of script-generated HTML -->
End of listing