Gayner Posted November 25, 2009 Share Posted November 25, 2009 Hi, How do i do add a for each session for each row? in the database ? Let's say i got $_SESSION['prayer']; I Want my user's session to beable to only prayer once for each prayer, let's say we got 423523 prayers in my database, I want him to beable to prayer for one prayer and not again on the same one, but prayer for another with a different idea. I have the mysql code to update db all that i just need ur help on how i would do a $_SESSION on this? Thanks for your patience. Quote Link to comment Share on other sites More sharing options...
Goldeneye Posted November 25, 2009 Share Posted November 25, 2009 Sorry, I can't quite understand your post. So, you want your users to be able to pray once on the same prayer? And then you want to load something into $_SESSION variables? Quote Link to comment Share on other sites More sharing options...
Gayner Posted November 25, 2009 Author Share Posted November 25, 2009 Sorry, I can't quite understand your post. So, you want your users to be able to pray once on the same prayer? And then you want to load something into $_SESSION variables? I want them not to beable to prayer more then twice on the same prayer. But there is 1 problem i have over 5215 prayers in my database. Quote Link to comment Share on other sites More sharing options...
trq Posted November 25, 2009 Share Posted November 25, 2009 I have the mysql code to update db all that i just need ur help on how i would do a $_SESSION on this? Sessions won't be of any help to you because they are removed when a bowser closes. Quote Link to comment Share on other sites More sharing options...
Gayner Posted November 25, 2009 Author Share Posted November 25, 2009 I have the mysql code to update db all that i just need ur help on how i would do a $_SESSION on this? Sessions won't be of any help to you because they are removed when a bowser closes. So how do i get guests to not beable to pray for a prayer more then twice? for that one, but can pray for other prayers only once but not twice, so only way i can do this is if i make them be logged in and have a table name called "nopray" and check it for each user when there trying to pray for that prayer? im sorry but u didn't get me Quote Link to comment Share on other sites More sharing options...
trq Posted November 25, 2009 Share Posted November 25, 2009 Are your users logged in already? All you need do is add the users id and the prayer id in a table once the user has prayed that prayer. Then, every time a user attempts a prayer you check this table for there id and the prayer id, if the record exists, deny them. Quote Link to comment Share on other sites More sharing options...
Gayner Posted November 25, 2009 Author Share Posted November 25, 2009 Are your users logged in already? All you need do is add the users id and the prayer id in a table once the user has prayed that prayer. Then, every time a user attempts a prayer you check this table for there id and the prayer id, if the record exists, deny them. Yea i have a login system but i want guests or users that arn' t logged in to beable to prayer for people too.. but only once.. that's why i beena sking about sessions ?? because some audience on my site our my baseball coaches for my team and they dont have time or no how to create account bla bla they are pastors they just want to read and click prayer button Quote Link to comment Share on other sites More sharing options...
trq Posted November 25, 2009 Share Posted November 25, 2009 Without a login, there is no reliable way to identify a user. Its that simple. You could store prayer id's in a cookie (though these can be removed). You could log ip addresses instead of user id using the method above (most ip addresses are however static and change regularly). Quote Link to comment Share on other sites More sharing options...
Gayner Posted November 25, 2009 Author Share Posted November 25, 2009 Without a login, there is no reliable way to identify a user. Its that simple. You could store prayer id's in a cookie (though these can be removed). You could log ip addresses instead of user id using the method above (most ip addresses are however static and change regularly). I havn't thought or got any rational thought on how i can do this Help? Quote Link to comment Share on other sites More sharing options...
trq Posted November 25, 2009 Share Posted November 25, 2009 I've given you the options, not sure what more I can do. Quote Link to comment Share on other sites More sharing options...
Gayner Posted November 26, 2009 Author Share Posted November 26, 2009 Are your users logged in already? All you need do is add the users id and the prayer id in a table once the user has prayed that prayer. Then, every time a user attempts a prayer you check this table for there id and the prayer id, if the record exists, deny them. That makes no sense, my user id is 50 and a prayer id can range from anywhere from 1 to 5331 rows i have. ? Quote Link to comment Share on other sites More sharing options...
trq Posted November 26, 2009 Share Posted November 26, 2009 It makes perfect sense, your just not thinking like a programmer. Lets say a user has just prayed for prayer number 11245, you have this number within $prayerid and the users id within $userid. All you need to do is inert these details into a prayed table. INSERT INTO prayed (userid, payerid) VALUES ($userid, $prayerid); Now, if the go to pray again, just check this table. $sql = "SELECT userid FROM prayed WHERE userid = $userid && payerid = $prayerid"; if ($result = mysql_query($sql)) { if (mysql_num_rows($result)) { echo "Sorry, you have already pryed this prayer"; } else { // allow them to prayer. } } The logic really is quite simple if you actually think about the problem. Quote Link to comment Share on other sites More sharing options...
Gayner Posted November 26, 2009 Author Share Posted November 26, 2009 It makes perfect sense, your just not thinking like a programmer. Lets say a user has just prayed for prayer number 11245, you have this number within $prayerid and the users id within $userid. All you need to do is inert these details into a prayed table. INSERT INTO prayed (userid, payerid) VALUES ($userid, $prayerid); Now, if the go to pray again, just check this table. $sql = "SELECT userid FROM prayed WHERE userid = $userid && payerid = $prayerid"; if ($result = mysql_query($sql)) { if (mysql_num_rows($result)) { echo "Sorry, you have already pryed this prayer"; } else { // allow them to prayer. } } The logic really is quite simple if you actually think about the problem. Oh, I never thought of making a new table, but i guess that is probably the most effectiveness way to go around this? Cause I think there is a easier way or probably not because your smart. lol Thanks alot for this Thorpe :-) good idea 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.