Jump to content

JoseN

Members
  • Content Count

    15
  • Joined

  • Last visited

Community Reputation

0 Neutral

About JoseN

  • Rank
    Member
  1. Thanks Barand! you mean broadcasting it here in the forum? it is just dummy data or you mean other way?
  2. Barand - I got it to work using the OnClick button! I was able to pass the userID and rewardID using only one button. Now when i redeem a reward for a specific user, it inserts the reward negative value to the points table just for that single user. The total points column now it looks better. I hope this definitely worked! I will test it later to make sure. I got a different question. Is it possible to hide or encrypt the names of the PHP files in the URL when an user is browsing them? For example, www.domain.com/view_users.php to something like this www.domain.com/tsds$ds.php After redeeming rewards
  3. With the data_id attribute will I be able to insert the reward value when clicking just one redeem button? the goal would be to just have one button in every record that will be able to insert the reward negative value into the right user and getting the right reward.
  4. I just did it.. when using just SELECT when clicking redeem for one user it shows the negative value assign to that user but also other users. In the screenshot attached I redeemed beer for George which the reward is 5 points, it assign the -5 to George but also to Sandy. That is not good! Lol
  5. Barand - Too good to be true! It is not working.... When redeeming a reward it inserts the negative values (reward value) to all users in the points table. I think it is because the userID is not being picked up when clicking the redeem button. Any ideas? Below is the current INSERT query which runs when clicking the button. Thanks in advance. $rewardid = $_GET['rewardID']; $qq = "INSERT INTO points (userID, loginTime, pointsEarned) SELECT usersTable.userID, NOW(), (0 - rewardListTable.valuePoints) AS redeemPoints FROM users usersTable, rewardsList rewardListTable, points pointsTable WHERE usersTable.userID = pointsTable.userID AND rewardListTable.rewardID = $rewardid GROUP BY pointsTable.userID";
  6. Got it! Thanks a lot again. You have been pretty helpful. I am a beginner in the PHP and databases world so your help has been very helpful.
  7. Thanks Barand! I got it to work!! the problem for the double entering was that I was not grouping the user by its ID. I just used in the INSERT INTO SELECT query the GROUP BY clause. That was the problem! I HOPE! LOL! I will test it more. regarding the storage of the totals. is it best practices to not store calculated values in a database?
  8. Thanks a lot for all your help Barand! I think a made it work with the current button I have. I just added this line to the mysql query. WHERE usersTable.userID = pointsTable.userID AND rewardListTable.rewardID = $rewardid"; Instead of getting the userID from the button I am getting the rewardID and I am just matching the userID from the users Table to the Points Table userID. It seems to be working BUT now I have another problem and maybe it is related to the above line of code. When I redeem a reward it inserts the negative value of the reward into the points table as it is supposed. It does that only the first time a reward is redeemed. Any time after that, it double inserts the negative value of any reward I redeem instead of only one time. Below are some screen shots and the code I have in the INSERT query which I believe where the problems is. What do you think? When redeeming milk (10 points) the first time When redeeming Beers d (5 points). This when redeeming for a second time INSERT INTO QUERY $qq = "INSERT INTO points (userID, loginTime, pointsEarned) SELECT usersTable.userID, NOW(), (0 - rewardListTable.valuePoints) AS redeemPoints FROM users usersTable, rewardsList rewardListTable, points pointsTable WHERE usersTable.userID = pointsTable.userID AND rewardListTable.rewardID = $rewardid"; This UPDATE query rungs after the insert $query = "UPDATE users usertable INNER JOIN (SELECT userID, SUM(pointsEarned) as totalpoints FROM points GROUP BY userID) pointstable ON usertable.userID = pointstable.userID SET usertable.TotalPoints = pointstable.totalpoints";
  9. I got to work this query... it gets the userID from the delete/redeem button on the table then using the rewardID (33) assigns the reward's value to the points table. It seems that is working but I need to get the rewardID from somewhere because I can't manually entered in the code. is it possible to get two values from one single button. I am just thinking a loud here. Thanks Barand. $userid = $_GET['userID']; $qq = "INSERT INTO points (userID, loginTime, pointsEarned) SELECT usersTable.userID, NOW(), (0 - rewardListTable.valuePoints) AS redeemPoints FROM users usersTable, rewardsList rewardListTable WHERE usersTable.userID = $userid AND rewardListTable.rewardID = 33"; mysqli_query ($dbc, $qq); BUTTON <div class="btn-group"> <div class="col text-center"> <button type="submit" class="btn btn-sm btn-primary" onclick="check('.$row['userID'].'); return false;">Delete</button> </div> SCRIPT FOR BUTTON <script type="text/javascript"> function check(userID) { if (confirm("Are you sure you want to delete this?")) this.location.href = "?userID="+userID; }</script>
  10. writing a record using INSERT INTO SELECT query right?
  11. Barand - Quick question... if want to delete the actually reward from the table and the associated points from the user total points.. how could I do that? basically instead of the redeem button in there I would have a delete button. Then for example, I would want to delete the Milk reward from Abel Villa but once I do that the 10 points from that ward will be subtracted from Abel's total points. Any ideas? I am not really sure how to go about that. Thanks in advance!
  12. Barand - Thank you so much! It worked! I didn't know It was possible to join two tables without any relationship. You just showed me how. Thanks again!
  13. requinix - A user logins to the web. Then, login time, date , user name, and earned points are inserted in another table (not shown). The points are being inserted based on the days the user logged in. For example, if the user logs in on a Sunday, then he gets 5 points, if he logs in on a Monday, then he gets 15 days... so on. During the week is 15 points and weekends 5 points. Thanks for your help!
  14. Barand - I am so sorry! My slow ass was not paying attention when I posted the topic. I just fixed the image. Basically, I want to output that just user has earned a reward based on the total points they earned.I wanted to keep the rewards separate from the users since the rewards table will be updated often with different rewards. I am not sure If it is a little bit better explained. thank you for your help.
  15. hello all - I need help figuring out an idea I want to do in my PHP web app using a MYSQL query. The picture attached explains my idea. Can you guys help me out? Thank You in Advanced,
×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.