So I'm redoing the page, and trying to use what I've learned from my other threads, and using If/ELSE IF's.
one problem I'm running into is a check to make sure the player has enough gold to get the other player out.
When the page first loads, I have a variable named $heal which is this
Code: Select all
$heal = round(($alldead['dead_time_remaining']-$currenttime)*100);
So now, I'm trying to use that to make sure the player paying the bills has enough, but it's not working. I think it's because of where I have that variable defined. I've tried to echo $heal in my if statement, and nothing appears.
but I've also tried moving it, but then it doesn't calculate the amount correctly anymore for each player.
I've attached my original medical ward as reference, and here is the code I'm trying to change it too.
Anyone know what I'm doing wrong?
I've tried changed my IF to ($player->gold < 500000) as a test, and it said I didn't have enough gold.
So I think the IF is OK??
Code: Select all
<?php
include("templates/private_header.php");
$currenttime = time();
$getdead = $db->execute("SELECT b.*, d.username AS killedby, c.name as weapon FROM players d
Inner JOIN players b ON b.Killed_by_ID = d.id
Inner JOIN blueprint_items c ON b.Weapon_Used_ID = c.id
Where b.dead_time_remaining > $currenttime
ORDER BY dead_time_remaining");
$totaldead = $getdead->recordcount();
if ($_GET['act'] == "go") {
$getdead = $db->execute("SELECT `username`, `dead_time_remaining`, `id` FROM `players` where `id`=?", array($_GET['id']));
$getdeadplayer = $getdead->fetchrow(); //get dead player from link.
// check that patient is not self
if ($player->id == $getdeadplayer['id'])
{
echo "You cannot buy yourself out of the hospital, you must wait it out or use items from your inventory";
}
//check if player has enough gold
else if ($player->gold < $heal)
{
echo "You don't have enough cash to pay this players medical bills";
echo $heal;
}
}
else
{
echo "<table width=\"100%\" border=\"1\">";
echo "<tr>" ;
echo "<td width=\"55%\"><strong>Patient</strong></td>";
echo "<td width=\"13%\"><div align=\"center\"><strong>Time Left</strong></div></td>";
echo "<td width=\"32%\"><div align=\"center\"><strong>Pay Patients Bills</strong></div></td></tr>";
while($alldead = $getdead->fetchrow())
{
echo "<tr><td>";
echo $alldead['username'] . "\n";
echo "was killed by \n" . $alldead['killedby'] . "'s\n" ;
echo $alldead[weapon];
echo "</td>\n";
echo "<td <div align=\"center\">" . round(($alldead['dead_time_remaining']-$currenttime)/60);
echo "</td>";
$heal = round(($alldead['dead_time_remaining']-$currenttime)*100);
echo "<td><div align=\"center\">$". number_format($heal) . "<br>";
echo "<a href=\"medical_ward.php?act=go&id=". $alldead['id'] ."\">Pay Bill</a></td>";
}
echo "</table>\n<p></p>";
echo "<b>Total Players who got the turds beat out of them.\n". $totaldead;
}
include("templates/private_footer.php");
?>