help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
InnerShadow
Forum Commoner
Posts: 37
Joined: Thu Nov 10, 2005 10:44 pm
Location: US

help

Post by InnerShadow »

okay, i have a couple of different tables for a game that i am creating. One of them contains alliances between different contries, the other one contains where their navies are.

Code: Select all

mysql_select_db("countries", $conn);

$result = mysql_query("SELECT Free19th, Free20th FROM war WHERE country = '$ID'") 
  or die(mysql_error()); 
while($row = mysql_fetch_assoc($result))
{
  $Free19th = $row['Free19th'];
  $Free20th = $row['Free20th'];
}

mysql_select_db("countries", $conn);

$result = mysql_query("SELECT UnitedStates, GreatBritain, France, Spain, Nicaragua, Hawaii, Panama, Jamaica, India, Sudan, Libya, Algeria, Vietnam, CostaRica, Philippines, China, PuertoRico, Cuba FROM war WHERE Country = '$ID'") 
  or die(mysql_error()); 
while($row = mysql_fetch_assoc($result))
{
 $UnitedStates = $row['UnitedStates'];
 $GreatBritain = $row['GreatBritain'];
 $France = $row['France'];
 $Spain = $row['Spain'];
 $Nicaragua = $row['Nicaragua'];
 $Hawaii = $row['Hawaii'];
 $Panama = $row['Panama'];
 $Jamaica = $row['Jamaica'];
 $India = $row['India'];
 $Sudan = $row['Sudan'];
 $Libya = $row['Libya'];
 $Algeria = $row['Algeria'];
 $Vietnam = $row['Vietnam'];
 $CostaRica = $row['CostaRica'];
 $Philippines = $row['Philippines'];
 $China = $row['China'];
 $PuertoRico = $row['PuertoRico'];
 $Cuba = $row['Cuba'];
 
}
$BockadeCheck = "no";
if($UnitedStates > $Free19th + $Free20th){
	print "You are currently under blockade by the United States Navy<br>";
	$BlockadeCheck = "yes";
}//end if
$BockadeCheck = "no";
if($UnitedStates > $Free19th + $Free20th){
	print "You are currently under blockade by the United States Navy<br>";
	$BlockadeCheck = "yes";
	$UnitedStatesBlockadeCheck = "yes"
}//end if
if($GreatBritain > $Free19th + $Free20th){
	print "You are currently under blockade by the British Navy<br>";
	$BlockadeCheck = "yes";
	$GreatBritainBlockadeCheck = "yes";

if($France > $Free19th + $Free20th){
	print "You are currently under blockade by the French Navy<br>";
	$BlockadeCheck = "yes";
	$FranceBlockadeCheck = "yes";
}//end if
if($Spain > $Free19th + $Free20th){
	print "You are currently under blockade by the Spanish Navy<br>";
	$BlockadeCheck = "yes";
	$SpainBlockadeCheck = "yes";
}//end if
if($Nicaragua > $Free19th + $Free20th){
	print "You are currently under blockade by the Nicaraguan Navy<br>";
	$BlockadeCheck = "yes";
	$NicaraguaBlockadeCheck = "yes";
}//end if
if($Hawaii > $Free19th + $Free20th){
	print "You are currently under blockade by the Hawaiian Navy<br>";
	$BlockadeCheck = "yes";
	$HawaiiBlockadeCheck = "yes";
}//end if
if($Panama > $Free19th + $Free20th){
	print "You are currently under blockade by the Panamanian Navy<br>";
	$BlockadeCheck = "yes";
	$PanamaBlockadeCheck = "yes";
}//end if
if($Jamaica > $Free19th + $Free20th){
	print "You are currently under blockade by the Jamaican Navy<br>";
	$BlockadeCheck = "yes";
	$JamaicaBlockadeCheck = "yes";
}//end if
if($India > $Free19th + $Free20th){
	print "You are currently under blockade by the Indian Navy<br>";
	$BlockadeCheck = "yes";
	$IndiaBlockadeCheck = "yes";
}//end if
if($Sudan > $Free19th + $Free20th){
	print "You are currently under blockade by the Sudanese Navy<br>";
	$BlockadeCheck = "yes";
	$SudanBlockadeCheck = "yes";
}//end if
if($Libya > $Free19th + $Free20th){
	print "You are currently under blockade by the Libyan Navy<br>";
	$BlockadeCheck = "yes";
	$LibyaBlockadeCheck = "yes";
}//end if
if($Algeria > $Free19th + $Free20th){
	print "You are currently under blockade by the Algerian Navy<br>";
	$BlockadeCheck = "yes";
	$AlgeriaBlockadeCheck = "yes";
}//end if
if($Vietnam > $Free19th + $Free20th){
	print "You are currently under blockade by the Vietnamese Navy<br>";
	$BlockadeCheck = "yes";
	$VietnamBlockadeCheck = "yes";
}//end if
if($CostaRica > $Free19th + $Free20th){
	print "You are currently under blockade by the Costa Rican Navy<br>";
	$BlockadeCheck = "yes";
	$CostaRicaBlockadeCheck = "yes";
}//end if
if($Philippines > $Free19th + $Free20th){
	print "You are currently under blockade by the Philippine Navy<br>";
	$BlockadeCheck = "yes";
	$PhilippinesBlockadeCheck = "yes";
}//end if
if($China > $Free19th + $Free20th){
	print "You are currently under blockade by the Chinese Navy<br>";
	$BlockadeCheck = "yes";
	$ChinaBlockadeCheck = "yes";
}//end if
if($PuertoRico > $Free19th + $Free20th){
	print "You are currently under blockade by the Puerto Rican Navy<br>";
	$BlockadeCheck = "yes";
	$PuertoRicoBlockadeCheck = "yes";
}//end if
if($Cuba > $Free19th + $Free20th){
	print "You are currently under blockade by the Cuban Navy<br>";
	$BlockadeCheck = "yes";
	$CubaBlockadeCheck = "yes";
}//end if
That part checks for blockades by a single country. What i need to do is to check for alliances, and if any are found, check if both of those countries have navies blockading a certain country, and then check if the number of navies that they have is greater then the Free19th + Free20th. Not exactly sure how to go about this.
Post Reply