...

View Full Version : Use session variables in recordset



Sn0man
05-17-2011, 01:57 AM
Hi there!

I'm brand new to the forum and a n00b at PHP and sql - so don't mind me if i'm talking jibberish...

that said -

I'm looking for a way to create a recordset based on session variables.

I have a sql table that contains four feilds: UserID, ItemDescription, ItemAmt and ItemName. When a client logs into my site, I store their userID and other info in session variables.

When they have a balance owing, I want to show a region that displays these feilds, and a "pay now" button. The payment functionality has already been created. When no balance is owing, I want to show a region that reflects that, or simply says something like "you have no current balance" or whatever.

The problem i'm having with the 'show region server behavior' is that when I use 'show if recordset is not empty', it will always show because the UserID feild is never empty. Therefore I need to find a way to only show that region if the other 3 feilds are empty.

I hope i'm making sense here.

Can anyone help out a n00b?

Thanks in advance

SKY-ProToSs
05-17-2011, 03:55 AM
Hi there!

I'm brand new to the forum and a n00b at PHP and sql - so don't mind me if i'm talking jibberish...

that said -

I'm looking for a way to create a recordset based on session variables.

I have a sql table that contains four feilds: UserID, ItemDescription, ItemAmt and ItemName. When a client logs into my site, I store their userID and other info in session variables.

When they have a balance owing, I want to show a region that displays these feilds, and a "pay now" button. The payment functionality has already been created. When no balance is owing, I want to show a region that reflects that, or simply says something like "you have no current balance" or whatever.

The problem i'm having with the 'show region server behavior' is that when I use 'show if recordset is not empty', it will always show because the UserID feild is never empty. Therefore I need to find a way to only show that region if the other 3 feilds are empty.

I hope i'm making sense here.

Can anyone help out a n00b?

Thanks in advance

Not sure how you'd do that. Maybe you shouldn't use the session variables to detect that? If you have a:

!empty($_SESSION['user'])

Maybe there's a way to create an on off loop that doesn't require it. I know that's not much, but I'm assuming it's a bad idea to just use that.

Sn0man
05-17-2011, 06:21 PM
Thanks for the reply

I did manage to find a solution, using a "show if condition is true" function.

<?php if ($row_rsPmts['ItemAmt']>"0"){ ?>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum