czukoman20 Posted August 17, 2007 Share Posted August 17, 2007 Hello, i'm a noob that needs help with a little bit of coding I have 2 pictures of my mysql database that are setup. The highlighted area in the pictures shows you what i would like to concentrate on. http://www.czartgaming.com/testpages/help/phpMyadmin.jpg http://www.czartgaming.com/testpages/help/phpMyadmin2.jpg What i would like to do is have it so the user can click on a button, then that will update that num_clicks info to +1. so everytime the user clicks that button... it will update with 1 added to that database. i need help with using the query function i believe, and to make it so i can do this. so if i'm confusing people with my wording. num_clicks = 1 when the user clicks the button ... num_clicks = 2 when the user clicks it again ... num_clicks = 3 Help is greatly appreciated Quote Link to comment https://forums.phpfreaks.com/topic/65465-solved-query-issues/ Share on other sites More sharing options...
MadTechie Posted August 17, 2007 Share Posted August 17, 2007 what do you have so far? Quote Link to comment https://forums.phpfreaks.com/topic/65465-solved-query-issues/#findComment-326879 Share on other sites More sharing options...
czukoman20 Posted August 17, 2007 Author Share Posted August 17, 2007 this is what i've got soo far just for this particular area mysql_select_db('czartga_login') or die('Error, cannot select mysql database'); $query="update users set num_clicks='+1'"; $result=mysql_query($query); Quote Link to comment https://forums.phpfreaks.com/topic/65465-solved-query-issues/#findComment-326895 Share on other sites More sharing options...
MadTechie Posted August 17, 2007 Share Posted August 17, 2007 try mysql_select_db('czartga_login') or die('Error, cannot select mysql database'); $query="update users set num_clicks=(num_clicks+1) "; $result=mysql_query($query); Quote Link to comment https://forums.phpfreaks.com/topic/65465-solved-query-issues/#findComment-326925 Share on other sites More sharing options...
czukoman20 Posted August 17, 2007 Author Share Posted August 17, 2007 thanks it worked, but i noticed tho that it updated the num_clicks to + 1 to all three accounts on there. //.pfft how can i designate it to one user? Quote Link to comment https://forums.phpfreaks.com/topic/65465-solved-query-issues/#findComment-326997 Share on other sites More sharing options...
MadTechie Posted August 17, 2007 Share Posted August 17, 2007 mysql_select_db('czartga_login') or die('Error, cannot select mysql database'); $query="update users set num_clicks=(num_clicks+1) WHERE userid=$uid"; $result=mysql_query($query); Note the userid=$uid your need to change this to suit your script/db Quote Link to comment https://forums.phpfreaks.com/topic/65465-solved-query-issues/#findComment-327019 Share on other sites More sharing options...
czukoman20 Posted August 17, 2007 Author Share Posted August 17, 2007 ok well i tried what you said to do after that, but it doesnt work at all now. i can get it to work for all of that row, but not just for that one user. I tried the username variable that i set earlier, and i know that works, because its saying the username on the page that i'm using for it, and i even tried typing in the username manually. still didnt work. so if you have any other options, that would be great mysql_select_db('czartga_login') or die('Error, cannot select mysql database'); $query="update users set num_clicks=(num_clicks+1) WHERE userid=$username"; $result=mysql_query($query); that is what i used Quote Link to comment https://forums.phpfreaks.com/topic/65465-solved-query-issues/#findComment-327096 Share on other sites More sharing options...
MadTechie Posted August 17, 2007 Share Posted August 17, 2007 the problem is here userid=$username whats the name of the field in the database that holds the username? find that and change it ie username='$username' Quote Link to comment https://forums.phpfreaks.com/topic/65465-solved-query-issues/#findComment-327143 Share on other sites More sharing options...
czukoman20 Posted August 18, 2007 Author Share Posted August 18, 2007 the field of the database for the username is named username. i'm not catchin ur drift Quote Link to comment https://forums.phpfreaks.com/topic/65465-solved-query-issues/#findComment-327245 Share on other sites More sharing options...
czukoman20 Posted August 18, 2007 Author Share Posted August 18, 2007 oo ok thanks it worked. helpin the noob out Quote Link to comment https://forums.phpfreaks.com/topic/65465-solved-query-issues/#findComment-327290 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.