Refresh to notice difference?
Posted: Sat Jun 19, 2010 2:36 pm
Hello guys,
Below i have supplied test code that I have been playing with to try and figure out why its not working on my official page. Of course its much more simplified but you get the idea.
Description/Run Through: So basically I have it accessing a row in my database, and then getting a variable in the "cash" column. I have a button that if pressed, it takes my cash and subtracts one from it. "Button Pressed" Was added to make sure the button was being pressed, which is was. Then it updates the new cash level back into the database. On the page it displays the button and the variable for total cash.
Problem: When I press the button it, gets the new variable and puts it in the database. But it doesn't change visually until I refresh the page.
Link: http://terminaldirective.site90.net/test.php
Code:
Thanks in Advance!
Birdum
Below i have supplied test code that I have been playing with to try and figure out why its not working on my official page. Of course its much more simplified but you get the idea.
Description/Run Through: So basically I have it accessing a row in my database, and then getting a variable in the "cash" column. I have a button that if pressed, it takes my cash and subtracts one from it. "Button Pressed" Was added to make sure the button was being pressed, which is was. Then it updates the new cash level back into the database. On the page it displays the button and the variable for total cash.
Problem: When I press the button it, gets the new variable and puts it in the database. But it doesn't change visually until I refresh the page.
Link: http://terminaldirective.site90.net/test.php
Code:
Code: Select all
<?php
mysql_connect("-", "-", "-") or die(mysql_error());
mysql_select_db("-") or die(mysql_error());
$data = mysql_query("SELECT * FROM mem_resources WHERE username = 'Birdum'") or die(mysql_error());
while ($row = mysql_fetch_assoc($data))
{
$totalcash = $row['cash'];
}
if ($_POST['buy'])
{
echo "Button pushed";
$totalcash = $totalcash - 1;
mysql_query("UPDATE mem_resources SET cash = '$totalcash' WHERE username = 'Birdum'") or die(mysql_error);
}
echo "<form method='POST'>";
echo "<input type='submit' name='buy' value='Buy Mines'>";
echo "</form>";
echo "Current Cash: $totalcash";
?>Birdum