
05-12-2006, 17:20
|
|
|
|
חבר מתאריך: 13.07.06
הודעות: 326
|
|
|
בניית פונקציה
שלום,
אני בונה משחק ואני רוצה לעשות כוח התקפה והגנה.
בניתי פונקציה שמתאימה נשקים לחיילים.
אבל אם יש 5 חיילים ו10 נשקים.
הפונקציה מתאימה את חמשתהנשקים הכי טובים.
הנה הקוד:
קוד PHP:
<html> <head> <title>Base</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <link rel="shortcut icon" href="logo2.png"> </head> <body> <font size="4">Base<br></font><br clear=all> <? $connection = mysql_connect ('localhost','yyy','xxx') or die (mysql_error ()); mysql_query("SET NAMES 'utf8'", $connection); mysql_select_db ('72768') or die (mysql_error ()); $name=$_POST["name"]; $pass=$_POST["pass"]; $k=$_POSRT["k"]; //if($_POST["send"]){ if ($name && $pass){ $sql="SELECT * FROM `users` WHERE `name` = '$name' AND `pass` = '$pass'"; $query = mysql_query ($sql); if($result = mysql_fetch_array ($query)){
//the page here: $query2="SELECT * FROM '$k' WHERE `$name`=`name`"; $result = mysql_fetch_array ($query2); $wt=array(); $wt[1]=$result["wt1"]; $wt[2]=$result["wt2"]; $wt[3]=$result["wt3"]; $wt[4]=$result["wt"]; $wt[5]=$result["wt5"]; $wt[6]=$result["wt6"]; $wt[7]=$result["wt7"]; $wt[8]=$result["wt8"]; $wt[9]=$result["wt9"]; $wt[10]=$result["wt10"]; $s1=$result["s1"]; $i=1;
$n=array(); $n[2]=1.3; $n[2]=1.8; $n[3]=2; $n[4]=2.7; $n[5]=3.5; $n[6]=4.5; $n[7]=5.2; $n[8]=6; $n[9]=7; $n[10]=8.5;
function attack_power($wt[$i],$s1,$attackk_power,$i,$n,$t) {
while($i<=10){ if(wt[$i]=0) { $t=0; } else { $t=1; } $n++; $attack_power=$attack_power+($s1+$wt[$i])*$n[]*$t; $i++;
} echo $power_attack; }
/* $i is the number of the weapon $n is the nu,ber of the power fot the weapon */
} //} else { echo "<font color='red'>You are not a loged in member, pleas <a href='register.php'>register a new
account</a> or <a href='register.php'>log in</a>.</font></br>";
} } ?> </body></html>
אני לא ממש יודע מה הבעיה...והשרת המפגר שלי לא מראה שגיאות....
|