wwedude Posted July 25, 2008 Share Posted July 25, 2008 For example I have a table like: Username Password Email Points DudeEncrypted [email protected] Is their a code in PHP I could do, so when someone visits that page, it will add to points, x amount. So like when you visit a page, a specific user gets +3 to their points. Sorry if I sound like a MySQL newbie, after all, I am. Thanks! Link to comment https://forums.phpfreaks.com/topic/116533-add-x-amount/ Share on other sites More sharing options...
peranha Posted July 25, 2008 Share Posted July 25, 2008 Do they always get the same amount of points added for each visit?? Or will it change Link to comment https://forums.phpfreaks.com/topic/116533-add-x-amount/#findComment-599175 Share on other sites More sharing options...
wwedude Posted July 25, 2008 Author Share Posted July 25, 2008 Well it will be one set amount to add on for that page. So to answer your question, it will be the same amount. Link to comment https://forums.phpfreaks.com/topic/116533-add-x-amount/#findComment-599190 Share on other sites More sharing options...
cooldude832 Posted July 25, 2008 Share Posted July 25, 2008 carry the points as a php variable (or off another mysql table) <?php $points = 5; $userid = 12; ?> Update `table` Set Points = (Points+".$points.") Where UserID = '".$userid."' Link to comment https://forums.phpfreaks.com/topic/116533-add-x-amount/#findComment-599326 Share on other sites More sharing options...
secoxxx Posted July 25, 2008 Share Posted July 25, 2008 Maybe somthing like this? <?php $userid = $_SESSION['userid']; $points = $_SESSION['points']; if(isset($_SESSION['points'])) $_SESSION['points'] = $_SESSION['points']+ 3; else $_SESSION['points'] = 0; $con = mysql_connect("localhost","username","pass"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("database", $conn); mysql_query("UPDATE `table` (points,userid) VALUES (\"$points\", \"$userid\") ON DUPLICATE KEY UPDATE points='$points'"); mysql_close($conn); ?> Link to comment https://forums.phpfreaks.com/topic/116533-add-x-amount/#findComment-599336 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.