Location: PHPKode > projects > php Strategy Game Engine X > phpsgex/core-pages/battle.php
/* --------------------------------------------------------------------------------------
   Credits         : phpSGEx by Aldrigo Raffaele
   Last modified by: rafa50 19.06.2013
   Comments        : you can't atack your city!
-------------------------------------------------------------------------------------- */

if( isset($_GET['p']) ){
	$atkcity= (int)$_GET['p'];
	$qrc= mysql_query("SELECT * FROM city WHERE id =".$atkcity);
	if( mysql_num_rows($qrc) >0 ){
		$acinfo= mysql_fetch_array($qrc);
		if( $acinfo['owner'] == $me->user_id ){ header("Location: index.php"); end; }
		$body="<h3>You are ataking ".$acinfo['name']." city</h3> <table border='1' cellpadding='5'>
		<form method='post' action='index.php'> <input type='hidden' name='atkcity' value='$atkcity'>";
		$qrunt= mysql_query("SELECT * FROM `units` WHERE `owner_id` =".$me->user_id." AND `where` =".$me->city_id);
		while( $row= mysql_fetch_array($qrunt) ){
			$cuinf= mysql_fetch_array( mysql_query("SELECT * FROM t_unt WHERE id =".$row['id_unt']) );
			$body.= "<tr><td>".$cuinf['name']." (".$row['uqnt'].")</td> <td><input name='tuid".$row['id_unt']."' type='number' min='0' value='0' max='".$row['uqnt']."'></td></tr>";
		$body.="<tr><td colspan='2'><input type='submit' value='Atack!' ></td></tr></form></table>";
	} else header("Location: index.php");

if( isset($_GET['colnize']) ){
	$qrcolunt= mysql_query("SELECT * FROM `t_unt` WHERE `type` = 'column' LIMIT 1;");
	if( mysql_num_rows($qrcolunt) > 0 ){
		$aidcolunt= mysql_fetch_array($qrcolunt);
		$idcolunt= $aidcolunt['id'];
		$qrycu= mysql_query("SELECT * FROM `units` WHERE `id_unt` =$idcolunt AND `owner_id` =".$me->user_id." AND `where` =".$me->city_id." AND `action` =0 LIMIT 1;");	
		if( mysql_num_rows($qrycu) >0 ){
			$anumcu= mysql_fetch_array($qrycu);
			$numcu= $anumcu['uqnt']; 
		} else $numcu= 0;
		<form name='fc' id='fc' method='post' action='?pg=main' >
		<input type='hidden' name='gal' value='".$_GET['gal']."'>
		<input type='hidden' name='sys' value='".$_GET['sys']."'>
		<input type='hidden' name='pos' value='".$_GET['colonize']."'>
		Colonize:<br> ".$aidcolunt['name']." (colonizator): $numcu<br>";
		if( $numcu >0 ) $body.="<input type='submit' name='colonize' value='Colonize!' >";
		else $body.="<span class='Stile3'>You must have at least one ".$aidcolunt['name']."</span>";
Return current item: php Strategy Game Engine X