Jump to content

in_array() help?


drummer101

Recommended Posts

<?php
while($row = mysql_fetch_array($user_id))
     if(in_array(19, $row)){
          echo "ADMIN<br>";
     } else {
  echo "NOT<br>";
     }
} else {
     echo "You have entered an invalid username/password combination";
}
?>

$row is a sql select statement that will return a quantity of results > 2

 

right now the php codeblock returns, "ADMIN NOT NOT". I can't figure out how to get the loop to stop when it returns true. and continue looping until END or TRUE.

Link to comment
https://forums.phpfreaks.com/topic/95173-in_array-help/
Share on other sites

<?php
$res=mysql_query("SELECT * FROM users where username='$user' AND pass='$pass'");

if($row = mysql_fetch_array($user_id))
     if(in_array(19, $row)){
          echo "ADMIN<br>";
     } else {
  echo "NOT<br>";
     }
} else {
     echo "You have entered an invalid username/password combination";
}
?>

 

Link to comment
https://forums.phpfreaks.com/topic/95173-in_array-help/#findComment-487478
Share on other sites

One more question. Ran into a problem case checking. It appears that all of the results from $user_id aren't being returned, only the last one is.

 

user_id's are matched to group ID's, so you might have

 

User  Group ID

5        6

5        8

5        10

6        6

7        8

7        10

 

How would I go about assigning all the group ID's of user 5 to an array?

something like $this->sql->group_ids or am I way off base on that?

Link to comment
https://forums.phpfreaks.com/topic/95173-in_array-help/#findComment-487493
Share on other sites

Archived

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

×
×
  • 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.