3v4l.org

run code in 300+ PHP versions simultaneously
<?php header('Content-Type: image/png'); session_start(); //Initialising floor plan generation variables $vertxstart = 70; $vertystart = 70; $vertwidth = 31; $vertheight = 140; $horzwidth = 140; $horzheight = 31; $horzxstart = 970; $horzystart = 60; $rmodind = 8; $lmodind = 23; $moddrawsize = 8; $modgap = 15; $vertxincr = 60; $vertyincr = 169; $horzyincr = 60; $row = 1; $column = 1; $splitter = 1; //Initialising database connections for later use $user_name = "shoppin1_root"; $password = "ryan062098!"; $server = "localhost"; $database = "shoppin1_shop"; $db_handle = mysql_connect($server, $user_name, $password); $db_found = mysql_select_db($database, $db_handle); //Initialising image draw space $canvas = imagecreate(1200, 400); //Allocate colours $black = imagecolorallocate($canvas, 0, 0, 0); $white = imagecolorallocate($canvas, 255, 255, 255); $silver = imagecolorallocate($canvas, 192, 192, 192); $green = imagecolorallocate($canvas, 172, 250, 88); $blue = imagecolorallocate($canvas, 88, 211, 247); $red = imagecolorallocate($canvas, 250, 88, 88); //Fix implemented so image is transparent, so html background is shown in places not drawn imagefilltoborder($canvas, 0, 0, $silver, $silver); imagecolortransparent($canvas, $silver); //Draws vertical aisles on floor plan for ($row; $row < 3; $row++) { for ($column; $column < 15; $column++) { if ($row == 2 and ($column == 11 or $column == 12)) { //exception in algorithm to allow for clothes section } else { imagerectangle($canvas, $vertxstart, $vertystart, ($vertxstart + $vertwidth), ($vertystart + $vertheight), $black); imagerectangle($canvas, ($vertxstart + $rmodind), $vertystart, ($vertxstart + $rmodind + $modgap), ($vertystart + $vertheight), $black); imagerectangle($canvas, ($vertxstart + 3), ($vertystart + $vertheight), ($vertxstart + 28), ($vertystart + $vertheight + 8), $black); imagerectangle($canvas, ($vertxstart + 3), ($vertystart - 8), ($vertxstart + 28), $vertystart, $black); if ($row == 2) { $aislenumber = 15 - $column; //Moves aislenumber to bottom row of aisles } else { $aislenumber = 14 + $column; //Top row of aisles } $SQL = "SELECT rmods, lmods FROM isleinfo WHERE islenumber = '$aislenumber'"; $Result = mysql_query($SQL); while ($field = mysql_fetch_array($result)) { $rmods = $field['rmods']; $lmods = $field['lmods']; } mysql_close($db_handle); if ($aislenumber !== 1 and $aislenumber !== 28) { //exception for aisle 1 and 28 as right mods do not need to be drawn, main aisle is to the right $modsize = 200 / $rmods; for ($splitter; $splitter < $rmods; $splitter++) { imageline($canvas, $vertxstart, ($vertystart + ($modsize * $splitter) - 1), ($vertxstart + 8), ($vertystart + ($modsize * $splitter) - 1)); } } if ($aislenumber !== 14 and $aislenumber !== 15) { //exception for aisle 14 and 15 as left mods do not need to be drawn, back wall is to the left $modsize = 200 / $lmods; //Gets draw size of individual mod for ($splitter; $splitter < $lmods; $splitter++) { //draws lines to seperate mods visually on screen at correct co-ordinates imageline($canvas, ($vertxstart - 37), ($vertystart + ($modsize * $splitter) - 1), ($vertxstart - 29), ($vertystart + ($modsize * $splitter) - 1)); } } } $vertxstart = $vertxstart + $vertxincr; //Move to next aisle co-ordinates } $vertystart = $vertystart + $vertyincr; //Move to bottom row aisles } //Output and free from memory imagepng($canvas); imagedestroy($canvas); ?>

preferences:
52.39 ms | 402 KiB | 5 Q