mysql - PHP 'if' statement in SQL array -


i trying place if statement, including sql variable in echo'ing of sql array this;

error_reporting(e_all); $action = 'adddb'; $data = array(); function printusers () {     global $db;     $users = $db->get ("user_data     order date desc, time desc");     if ($db->count == 0) {         echo "<td align=center colspan=4>no users found</td>";         return;     }     foreach ($users $u) {         echo "<tr>             <td>{$u['user']}</td>";         $this_user = $db->objectbuilder()->where("username", "{$u['user']}")->getone('users');         if($this_user->group > 1) {             if($user->haspermission('moderator')) {                 echo "<td><i>administrator</i></td>";             } else {                 echo "<td>{$u['ip']}</td>";             }         }          echo "<td>{$u['os']}</td>             <td>{$u['browser']}</td>             <td>{$u['referer']}</td>             <td>{$u['date']}</td>             <td>{$u['time']}</td>         </tr>";     } } 

now, i've concluded 2 things wrong this;

  • it not seem me placing if statement there
  • it not me using {$u ... variable in statement...

i cannot seem figure out why though, php glasses on, doesn't seem wrong... (other {} in variable, removing them doesn't make different)

i have absolutely no clue wrong here, following errors didn't give me either.

is possible? , if so, sort-of on right track?

edit

i've tried following code, comments.

        echo "<tr>             <td>{$u['user']}</td>"; if(!$u['user'] == "guest") { $this_user = $db->objectbuilder()->where("username", $u['user'])->getone('users');     if($this_user->group > 1) {         if($user->haspermission('moderator')) {             echo "<td><i>administrator</i></td>";         } else {             echo "<td>{$u['ip']}</td>";         }     } }              echo "<td>{$u['os']}</td>             <td>{$u['browser']}</td>             <td>{$u['referer']}</td>             <td>{$u['date']}</td>             <td>{$u['time']}</td>         </tr>"; 

now no ip's displayed @ all.


Comments