james stone - 2013-05-17 03:48:34
Hello I am kinda of an intermediate PHP programmer, and I need help with the scripting part of, when you disconnect the power source the rest of the conductive blocks are discharged, but the more I think the more I see that it might not be possible, I am going to post the code to see if anyone can help.
while($data=mysql_fetch_array($all)){
if($data["active"]==0){
$color="white";
$status="1";
$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"]."'");
}
?>
<td bgcolor="<?=$color?>"><a href="change.php?status=<?=$status?>&id=<?=$data["ID"]?>" style="display:block;text-decoration:none;color:<?=$color?>;">##</a></td>
<?
if($data["rowend"]==1){
echo("</tr><tr>");
}
}