Another one for you guys (set sessions based on results)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ianhull
Forum Contributor
Posts: 310
Joined: Tue Jun 14, 2005 10:04 am
Location: Hull England UK

Another one for you guys (set sessions based on results)

Post by ianhull »

Hi Guys,

I have another little issue here.
I am selecting some fields from the database like this

Code: Select all

include_once("connect.php");
$myuserid = $_SESSION['myuserid'];
$getnav = "SELECT userid, module, level FROM security WHERE userid='$userid'";
$getnavresult = mysql_query($getnav) or die($getnav); 

while ($row = mysql_fetch_array($getnavresult)) 
extract($row);
I now need to get each results module name and level and store them in a seperate session variable like this

Code: Select all

$_SESSION['module1'] = $row1 etc
$_SESSION['module1level'] = $row1 etc
Can anyone please point me in the right direction?

Thanks
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Use an incremented variable?
ianhull
Forum Contributor
Posts: 310
Joined: Tue Jun 14, 2005 10:04 am
Location: Hull England UK

Post by ianhull »

Hi feyd,

I am not sure what that is,

I was thinking of something like (for each) but don't know how to use that.

Can you help?

thanks
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Try reading the manual on the looping functions (for, foreach, while, each, etc). You are the right track.
Post Reply