<?php
/*
    Little example made by Knuta <webmaster@partyreg.net>
    You are free to use this, but please give me credit ;)
    If you encounter bugs, please notify me...
*/

$map imagecreatefrompng("map.png");

// Some state
$yours 5// your seat
function is_taken($seat) {
    if (
in_array($seat, array(1,3,6,7,8))) {
        return 
true;
    }
    return 
false;
}

// Determining colors =)
$color_taken imagecolorclosest($map,255,0,0);
$color_yours imagecolorclosest($map,0,255,0);
$color_avail imagecolorclosest($map,255,255,255);

// Include seats
$seat = array();
$seat[1] = array(52,16,64,28);
$seat[2] = array(67,16,79,28);
$seat[3] = array(82,16,94,28);
$seat[4] = array(97,16,109,28);
$seat[5] = array(112,16,124,28);
$seat[6] = array(127,16,139,28);
$seat[7] = array(142,16,154,28);
$seat[8] = array(157,16,169,28);
$seat[9] = array(172,16,184,28);
$seat[10] = array(187,16,199,28);
$seat[11] = array(202,16,214,28);
$seat[12] = array(52,31,64,43);
$seat[13] = array(67,31,79,43);
// OK, that's enough. Getting tedious.

// Paint rectangles.
reset($seat);
while (
$pos each($seat)) {
    if (
$pos[0] == $yours) {
        
$color $color_yours;
    } else if (
is_taken($pos[0])) {
        
$color $color_taken;
    } else {
        
$color $color_avail;
    }
    
imagefilledrectangle($map,$pos[1][0],$pos[1][1],$pos[1][2],$pos[1][3],$color);
}

// Demo of writing text
imagestring($map,2,0,0,$yours,$color_yours);

// Outputting Image
Header("Cache-control: none");
Header("Pragma: no-cache");
Header("Content-type: image/png");

imagepng($map);
imagedestroy($map); 

?>