Dysan Posted November 14, 2007 Share Posted November 14, 2007 How do I create a link, that when clicked, increments a number value stored in a database? Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted November 14, 2007 Share Posted November 14, 2007 If you want to do this without reloading the page/redirecting, you'll have to use AJAX. Google AJAX and you'll see that you'll make javascript make a request to a php page which can handle the query to your database. Quote Link to comment Share on other sites More sharing options...
Dysan Posted November 14, 2007 Author Share Posted November 14, 2007 No, I want to reload the page each time. How do I create the links etc? Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted November 14, 2007 Share Posted November 14, 2007 You can create the link like this <a href="your_url.php?action=add">Click</a> Then on "your_url.php" put this code <?php if (isset($_GET['action']) && $_GET['action'] == 'add'){ $query = "UPDATE table SET number=number+1 WHERE condition"; $result = mysql_query($query)or die(mysql_error()); echo "DB updated"; } ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.