Updating without reloading the page
Posted: Sat Oct 15, 2005 2:03 pm
Jcart | Please use
How would you get it so that the calories is updated on that page? So that it says "Now it's only 400 calories!" WITHOUT RELOADING THE PAGE? Is that not possible?
Jcart | Please use
Code: Select all
andCode: Select all
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
Okay I'm a bit new to PHP.
Let's say the variable 'calories' is currently 450.Code: Select all
<?php
if($diet == "yes")
{
mysql_query("UPDATE mcdonalds set calories=calories-50 where id='1'");
$currentcal=mysql_fetch_array(mysql_query("SELECT calories from mcdonalds where id='1'"));
echo "Now it's only <b>$currentcal[calories]</b> calories!";
exit;
}
print "<a href=?diet=yes>Diet!</a>";
?>Jcart | Please use
Code: Select all
andCode: Select all
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]