wwedude Posted July 25, 2008 Share Posted July 25, 2008 For example I have a table like: Username Password Email Points DudeEncrypted Passwordblah@yahoo.com28 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! Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment 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."' Quote Link to comment 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); ?> 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.