Jump to content

For each $_SESSION? Possible?


Gayner

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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).

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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. ?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.