help with php game

ok, so i have decided to make a game using php and mysql, so far its working out GREAT, the game is like those circuit games, you can make a generator that produces power, and then there is a conductive wire, and when it is connected to another conducted wire or a power source it gets charged, my problem is, when the generator is disconnected the whole line is still charged and i need it to discharge. heres the important part of the code:

[php]$query=mysql_query(“UPDATE board SET name=‘plain’ WHERE ID=’”.$data[“ID”]."’");
}

elseif($data[“active”]==1){
$query=mysql_query(“UPDATE board SET name=‘conductive’ WHERE ID=’”.$data[“ID”]."’");

$one=$data[“ID”]-50;
$two=$data[“ID”]-1;
$three=$data[“ID”]+1;
$four=$data[“ID”]+50;

$topg=mysql_query(“SELECT * FROM board WHERE ID=’”.$one."’");
$top=mysql_fetch_array($topg);
$leftg=mysql_query(“SELECT * FROM board WHERE ID=’”.$two."’");
$left=mysql_fetch_array($leftg);
$rightg=mysql_query(“SELECT * FROM board WHERE ID=’”.$three."’");
$right=mysql_fetch_array($rightg);
$bottomg=mysql_query(“SELECT * FROM board WHERE ID=’”.$four."’");
$bottom=mysql_fetch_array($bottomg);

if($top[“name”]==“source”){$color=“yellow”;$query=mysql_query(“UPDATE board SET name=‘charged_s’ WHERE ID=’”.$data[“ID”]."’");}
elseif($left[“name”]==“source”){$color=“yellow”;$query=mysql_query(“UPDATE board SET name=‘charged_s’ WHERE ID=’”.$data[“ID”]."’");}
elseif($right[“name”]==“source”){$color=“yellow”;$query=mysql_query(“UPDATE board SET name=‘charged_s’ WHERE ID=’”.$data[“ID”]."’");}
elseif($bottom[“name”]==“source”){$color=“yellow”;$query=mysql_query(“UPDATE board SET name=‘charged_s’ WHERE ID=’”.$data[“ID”]."’");}

elseif($top[“name”]==“charged_s”){$color=“yellow”;$query=mysql_query(“UPDATE board SET name=‘charged’ WHERE ID=’”.$data[“ID”]."’");}
elseif($left[“name”]==“charged_s”){$color=“yellow”;$query=mysql_query(“UPDATE board SET name=‘charged’ WHERE ID=’”.$data[“ID”]."’");}
elseif($right[“name”]==“charged_s”){$color=“yellow”;$query=mysql_query(“UPDATE board SET name=‘charged’ WHERE ID=’”.$data[“ID”]."’");}
elseif($bottom[“name”]==“charged_s”){$color=“yellow”;$query=mysql_query(“UPDATE board SET name=‘charged’ WHERE ID=’”.$data[“ID”]."’");}

elseif($top[“name”]==“charged”){$color=“yellow”;$query=mysql_query(“UPDATE board SET name=‘charged’ WHERE ID=’”.$data[“ID”]."’");}
elseif($left[“name”]==“charged”){$color=“yellow”;$query=mysql_query(“UPDATE board SET name=‘charged’ WHERE ID=’”.$data[“ID”]."’");}
elseif($right[“name”]==“charged”){$color=“yellow”;$query=mysql_query(“UPDATE board SET name=‘charged’ WHERE ID=’”.$data[“ID”]."’");}
elseif($bottom[“name”]==“charged”){$color=“yellow”;$query=mysql_query(“UPDATE board SET name=‘charged’ WHERE ID=’”.$data[“ID”]."’");}

else{$color=“gray”;}
$status=“2”;
}

elseif($data[“active”]==2){
$color=“green”;
$status=“0”;
$query=mysql_query(“UPDATE board SET name=‘source’ WHERE ID=’”.$data[“ID”]."’");
}

?>

" style="display:block;text-decoration:none;color:<?=$color?>;">## <? if($data["rowend"]==1){ echo(""); } }[/php]
Sponsor our Newsletter | Privacy Policy | Terms of Service