tennis_mnky Posted April 14, 2010 Share Posted April 14, 2010 I made a program that asks for a grid size, makes a grid, and then displays it. On the first load it asks for information about size. On the second page it randomly makes a grid and displays it. On each page after its suppose to display the grid. However it is only printing the grid on the second page and not the ones after it. Here is the code <html> <body> <?php $count = $_REQUEST["count"]; $height = $_REQUEST["height"]; $width = $_REQUEST["width"]; $size = $_REQUEST["size"]; $born = array(1 => 3); $live = array( 1 => 2, 2=> 3); $grid = $_REQUEST["grid"]; $grid = unserialize ($grid); If ($count == 0) { ask($count); } elseif($count == 1) { $grid=makegrid($height,$width); $checker = table($grid,$height,$width,$size); print "$checker"; send ($grid,$count); } elseif ($count >= 2) { //$grid = livedie($grid,$born,$live,$height,$width); $checker = table($grid,$height,$width,$size); print "$checker"; send ($grid,$count); } print '<pre>' . print_r($grid, 1) . '</pre>'; function ask($c) { $c++; print <<<HERE <form method = "post"> <h1>Choose the size of the grid</h1> What height do you want: <input type = "text" name = "height"> <br>\n<br>\n What width do you want: <input type = "text" name = "width"> <br>\n<br>\n What size do you want? (1 is smallest): <input type = "text" name = "size"> <br>\n<br>\n <input type = "hidden" name = "count" value = "$c"> <br>\n<br>\n <input type = "submit"> </form> HERE; } //now define functions function makegrid($height,$width){ for($i =0; $i < $width; $i++) { for($n = 0; $n < $height; $n++) { $if = rand(0,1); //if is yes or no $grid[$n][$i] = $if;}} return $grid; } //end loop, end loop, end funcition //array is made with values of 0 or 1 function table($grid,$tableHeight, $tableWidth, $cellSize) { //Height and width of the cells $cellStyle = "height:{$cellSize};width:{$cellSize};"; $tableHTML = "<table border=\"0\" style=\"font-size:1pt;\">\n"; for ($row=0; $row<$tableHeight; $row++) { $tableHTML .= "<tr>\n"; for ($col=0; $col<$tableWidth; $col++) { $cellColor= ($grid[$row][$col]==1) ? "000000" : "F"; $tableHTML .= " <td width=\"0\" style=\"{$cellStyle}background-color:{$cellColor};\"> </td>\n"; } $tableHTML .= "</tr>\n"; } $tableHTML .= "</table>\n"; return $tableHTML; } function send($grid,$count) { $count++; $grid = serialize ($grid); print <<<HERE <form method = "post"> <input type = "hidden" name = "grid" value = "$grid"> <input type = "hidden" name = "count" value = "$count"> <input type = "submit"> </form> HERE; } ?> </body> </html> Link to comment https://forums.phpfreaks.com/topic/198579-problem-with-multiple-page-loads/ Share on other sites More sharing options...
Ken2k7 Posted April 15, 2010 Share Posted April 15, 2010 Please read #4 for Forum DOs - Forum DOs Link to comment https://forums.phpfreaks.com/topic/198579-problem-with-multiple-page-loads/#findComment-1042056 Share on other sites More sharing options...
tennis_mnky Posted April 15, 2010 Author Share Posted April 15, 2010 Am i missing any tags or anything like that because that might be my problem. Link to comment https://forums.phpfreaks.com/topic/198579-problem-with-multiple-page-loads/#findComment-1042684 Share on other sites More sharing options...
tennis_mnky Posted April 16, 2010 Author Share Posted April 16, 2010 Is there anybody who can please help me with the problem. Link to comment https://forums.phpfreaks.com/topic/198579-problem-with-multiple-page-loads/#findComment-1043337 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.