php - Issues outputting database information if a column has a selected word -


i attempting output information database, if record has 'pending' in column 'status' filled in. of right breaking , have multiple records 'pending' filled in, in column.

what doing wrong?

<?php $con = mysqli_connect("localhost", "root", "", "db"); $run = mysqli_query($con,"select * user_requests order id desc"); $numrows = mysqli_num_rows($run);      if( $numrows > 0) {         while($row = mysqli_fetch_assoc($run)){             $pending_id = $row['status'];                 if($pending_id == ["pending"]){                     $pending_id = $row['user_id'];                     $pending_firstname = $row['firstname'];                     $pending_lastname = $row['lastname'];                     $pending_username = $row['username'];                 }         }     }                 echo $pending_firstname; ?> 

update:

i first result this...

if( $numrows > 0) {         while($row = mysqli_fetch_assoc($run)){             $pending_id = $row['status'];                 if($pending_id == "pending"){                     $pending_id = $row['user_id'];                     $pending_firstname = $row['firstname'];                     $pending_lastname = $row['lastname'];                     $pending_username = $row['username'];                 }         }     }     if ($pending_firstname == true) {                     echo $pending_firstname;                 } else {                     echo "there no pending requests time.";                 }   ?> 

no need put string in square brackets match against it.

if($pending_id == "pending")... 

ok - try code..
need output user details inside loop, or over-written

if( $numrows ) {     while($row = mysqli_fetch_assoc($run)){                     if($row['status'] == "pending"){              $pending_id        = $row['user_id'];             $pending_firstname = $row['firstname'];             $pending_lastname  = $row['lastname'];             $pending_username  = $row['username'];              echo "$pending_firstname $pending_lastname $pending_username <br>";          }     } } 

Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -