Location: PHPKode > projects > php Strategy Game Engine X > phpsgex/adm/research.php
<?php
$body.="<script type='text/javascript'>
function showHide(id) {
	if (id.style.display != 'block') id.style.display = 'block';
	else id.style.display = 'none';
}
</script>";

//add new res
$racsel="<select name='race'><option value='0'>All</option>";
$qrac= mysql_query("SELECT * FROM races");
while( $racr= mysql_fetch_array($qrac) ) $racsel.="<option value='".$racr['id']."'>".$racr['rname']."</option>"; 
$racsel.="</select>";

$rescost="";
$qrres= mysql_query("SELECT * FROM resdata");
while( $ftr= mysql_fetch_array($qrres) ) $rescost.=$ftr['name'].": <input type='text' name='res".$ftr['id']."' value='0' size='3'> X: <input type='text' size='3' name='rmpl".$ftr['id']."' value='0'><br>";

$body.="<form method='post' action='?pg=research'></table> <h2>".$lang['adm_addresearch']."</h2> <table border='1' width='100%'> <tr> <td>".$lang['adm_name']."</td> <td>Cost / Moltiplier per level</td> </tr>
<tr> <td>".$lang['adm_name']." <input type='text' name='name'> <br>".$lang['adm_image']." <input type='text' name='img' value='null.gif' size='9'> <br>".$lang['reg_race']." $racsel</td> <td>$rescost Time: <input type='text' name='time' size='3' value='0'> X: <input type='text' name='timempl' value='0' size='3'></td> <td><input type='image' src='../img/icons/add-icon.png' onclick='document.thisform.submit()' name='addresearch' value=' ' /></td> </tr> </table></form>";

//edit res
$body.="<br><br><table border='1' width='100%'>";
$qr= mysql_query("SELECT * FROM t_research");
while( $row= mysql_fetch_array($qr) ){
	//select for race
	$racsel="<select name='race'><option value='0'>All</option>";
	$qrac= mysql_query("SELECT * FROM races");
	while( $racr= mysql_fetch_array($qrac) ) { 
		$racsel.="<option value='".$racr['id']."'";
		if( $racr['id']==$row['arac'] ) $racsel.="selected";
		$racsel.=">".$racr['rname']."</option>"; 
	}
	$racsel.="</select>";
	//select for resource cost
	$rescost="";
	$qrres= mysql_query("SELECT * FROM resdata");
	while( $ftr= mysql_fetch_array($qrres) ){
		$qrcost= mysql_query("SELECT * FROM `t_build_resourcecost` WHERE `build` =".$row['id']." AND resource =".$ftr['id']);
		if( mysql_num_rows($qrcost) ==0 ) { $cost=0; $molt= 0; }
		else {
			$ar= mysql_fetch_array($qrcost);
			$cost= $ar['cost'];	
			$molt= $ar['moltiplier'];
		}
		$rescost.=$ftr['name'].": <input type='text' size='3' name='res".$ftr['id']."' value='$cost'>
		 X: <input type='text' size='3' name='rmpl".$ftr['id']."' value='".$molt."'><br>";
	}
	
	$qrreqbud= mysql_query("SELECT * FROM `t_research_reqbuild` WHERE `research` =".$row['id']);
	$i=1; $reqbud="";
	while( $arb= mysql_fetch_array($qrreqbud) ) {
		$reqbud.="<select name='reqbud$i'>";
		
		$qrgetbuilds= mysql_query("SELECT * FROM t_builds");
		while( $gb= mysql_fetch_array($qrgetbuilds) ){
			if( $gb['id']!=$row['id'] ) {
				$reqbud.="<option value='".$gb['id']."' ";
				if( $gb['id']==$arb['reqbuild'] ) $reqbud.="selected";
				$reqbud.=">".$gb['name']."</option>";
			}
		}
			
		$reqbud.="</select>: <input type='text' name='levbud$i' value='".$arb['lev']."' size='1'></nobr> <br>";
		$i++;
	}
	
	$reqbud.="<nobr> <div id='radd".$row['id']."' style='display:none;'><select name='reqbud$i'>";
	$qrgetbuilds= mysql_query("SELECT * FROM t_builds");
	while( $gb= mysql_fetch_array($qrgetbuilds) ) if( $gb['id']!=$row['id'] ) $reqbud.="<option value='".$gb['id']."'>".$gb['name']."</option>";
	
	$reqbud.="</select>: <input type='text' name='levbud$i' value='0' size='1'></div></nobr> <br><a href='#' onclick=\"javascript: showHide(radd".$row['id'].");\">".$lang['adm_add']."</a>";
	
	$body.="<form method='post' action='?pg=research'><input type='hidden' name='editresearch' value='".$row['id']."' >
	<tr> <td style='text-align: left'>Name: <input type='text' name='name' value='".$row['name']."' size='15'> <br>".$lang['adm_image'].": <input type='text' name='img' value='".$row['img']."' size='9'> <br>".$lang['reg_race'].": $racsel</td> <td>$rescost Time: <input type='text' name='time' value='".$row['time']."' size='3'> X: <input type='text' size='3' name='timempl' value='".$row['time_mpl']."'></td> <td>$reqbud</td> <td><input type='image' src='../img/icons/b_edit.png' onclick='document.thisform.submit()' /> <a href='?pg=research&delresearch=".$row['id']."'><img src='../img/icons/x.png' /></a></td> </tr>";
}
$body.="</table>";
?>
Return current item: php Strategy Game Engine X