Jump to content

$row variable help


unknown gamer

Recommended Posts

Sorry for asking for so much help but I have a hard time learning from somethings, I learn better when someone explains how to do something, which is why I come here.Well I have a variable I guess: $row['status'] I want to set that as a variable $status or something. Right now I have a page echoing all the users and there names linking to there profile, but I am trying to make a check so if there status is moderator or administrator do this. I tried $status= administrator;if $row['status']= administrator{echo worked;}else{echo didn't work;}I bet that is wrong because $row['status'] is moderator and administrator... so I don't think I'm properly specifying which user i'm checking for...so it is confused (is my guess) but is there some sort of way to *unpack* this variable or something so you can check if there status is administrator for each and every user then do something if there status is administrator or not?

Link to comment
Share on other sites

$status = 0; // set to zero/false early in your code/* ... do your mysql call here */$row['status'] = "admin";if ($row['status'] == "admin") {$status = 1; // if an admin, set $status to one/true}/* do more stuff */if ($status) {  // if $status is trueecho 'worked';  // status is on/true}else {echo 'failed';  // status is off/false}

Link to comment
Share on other sites

$status= administrator;

$row['status'] = "admin";

Why would you retrieve data from a database only to use a constant value anyway? Unless I'm being extremely dense, that needs to be removed.

Link to comment
Share on other sites

$status= administrator;

$row['status'] = "admin";

Why would you retrieve data from a database only to use a constant value anyway? Unless I'm being extremely dense, that needs to be removed.

I don't know, probably cause I'm new to PHP/mysql? :) jlhaslip yours worked but how do I know which user it is on?http://gamingsite.byethost13.com/login/users.phpThere are more users, how do i know what user it is saying it worked for, or how would i get it to check it for each user?Cool, I got it to work, thanks.
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...