Jump to content

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

would

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

Work?

Link to comment
https://forums.phpfreaks.com/topic/95173-in_array-help/#findComment-487506
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.