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? Link to comment https://forums.phpfreaks.com/topic/77347-increment-number/ 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. Link to comment https://forums.phpfreaks.com/topic/77347-increment-number/#findComment-391578 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? Link to comment https://forums.phpfreaks.com/topic/77347-increment-number/#findComment-391585 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"; } ?> Link to comment https://forums.phpfreaks.com/topic/77347-increment-number/#findComment-391589 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.