Jump to content


Photo

using IF


  • Please log in to reply
No replies to this topic

#1 desithugg

desithugg
  • Members
  • PipPipPip
  • Advanced Member
  • 281 posts
  • LocationScarborough

Posted 08 April 2006 - 09:54 PM

okay i have a button that i only want to appear once a certain row in the DB is zero or below zero
i have tried
<?php
$link = mysql_connect('localhost', 'username', 'password');
if (!$link) {
   die('Could not connect: ' . mysql_error());
}
$db_selected = mysql_select_db('tpf');
if (!$db_selected) {
   die('Could not select database: ' . mysql_error());
}
$result = mysql_query("SELECT * from battle where me = '$user_currently_loged' LIMIT 1");
if (!$result) {
   echo 'Could not run query: ' . mysql_error();
   exit;
}
/* Use the result, assuming we're done with it afterwords */
$row = mysql_fetch_assoc($result);

/* Now we free up the result and continue on with our script */
mysql_free_result($result);
echo $dead = $row['my_hp']; ?>

thats the get there row that has to be below zero

<?php if ($dead == 0) {
echo
<form action="battle.php" method="post">
<input readonly type="HIDDEN" name="my_hp" maxlength="500" value="<?php
$link = mysql_connect('localhost', 'username', 'password');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
$db_selected = mysql_select_db('tpf');
if (!$db_selected) {
die('Could not select database: ' . mysql_error());
}
$result = mysql_query("SELECT (my_hp - (((((2 * your_level / 5 + 2 )  * your_attack * your_sp_attack / my_defence ) /  50 ) + 2 ) * 2000 / 100 )) FROM battle WHERE me = '$user_currently_loged'");
if (!$result) {
echo 'Could not run query: ' . mysql_error();
exit;
}
$row = mysql_fetch_row($result);

echo $row[0]; // 42
?>">
<input readonly type="HIDDEN" name="your_hp" maxlength="500" value="<?php
$link = mysql_connect('localhost', 'user', 'password');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
$db_selected = mysql_select_db('tpf');
if (!$db_selected) {
die('Could not select database: ' . mysql_error());
}
$result = mysql_query("SELECT (your_hp - (((((2 * my_level / 5 + 2 )  * my_attack * my_sp_attack / your_defence ) /  50 ) + 2 ) * 2000 / 100 )) FROM battle WHERE me = '$user_currently_loged'");
if (!$result) {
echo 'Could not run query: ' . mysql_error();
exit;
}
$row = mysql_fetch_row($result);

echo $row[0]; // 42
?>">
<br>
<input type="submit" name="submit" value="Lost">
</form>?>

this is what i have tried but it didnt seem to work so if any11 can help me with that id greatly appreciate it




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users