Login   Register  
PHP Classes
elePHPant
Icontem

PHP, MySQL, HTML

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us

      Top level forums  >  PHP Specialists  >  General  >  PHP, MySQL, HTML  
Subject:PHP, MySQL, HTML
Summary:Electricity grid game help.
Messages:2
Author:james stone
Date:2013-05-16 14:12:14
Update:2013-07-22 06:49:40
 

  1. PHP, MySQL, HTML   Reply  
Picture of james stone
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>");
}
}

There is 1 reply in this thread, which is not being displayed.
Browsing this forum thread replies is available only to premium subscribers.


Go to the premium subscriptions page to learn how to become a premium subscriber and have full access to this forum.