php - How to select one result from same multiple database results -


i creating inbox page echoed out rows of user inbox database user appears multiple times appeared on database table if know mean, here image of mean: enter image description here

so name kanayo great appears times appeared in table. want name appear once when clicked on display message body.

here code:

    $mymsg = mysql_query("select msg_from, msg_to message msg_from='$my_id' or msg_to='$my_id' order msg_id desc limit $start, $per_page"); while($run_msg = mysql_fetch_array($mymsg)){     $msg_from = $run_msg['msg_from'];     $msg_to = $run_msg['msg_to'];     if($msg_from == $my_id){         $users = $msg_to;     } else {         $users = $msg_from;     }     $firsts = getuser($users, 'first');     $nicks = getuser($users, 'nick');     $lasts = getuser($users, 'last');  echo "<div align='left'><a href='message.php?user=$users' style='text-decoration:none;><<b><font color='blue'>$firsts $nicks $lasts</font</b></a></div><br>";     } 

i have functions , db connection in external files included.

enter image description here

this image of table, don't know if right table structure inbox.

best way move condition (checking if equal my_id mysql query, , let resulting variable "users"). , end of query, can add;

group users 

which make sure pull distinct "users"

you can incorporate condition mysql using if element, i.e.

select if(msg_from = '$my_id', msg_to, msg_from) users 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -