Php and MySQL Querys using values in other tables -


so i'm trying fetch of user_id's users-events table event_id equal passed in variable (let's it's 2 now.)

in database there 2 id's registered event_id 1 , 2.

this code returns first of these values. feel need incorporate first query while loop dont know how go it.

any appriciated!

function showregisteredplayers($id){  $eventq = mysql_fetch_assoc(mysql_query("select user_id `users-events` event_id = '".$id."'")); $rosterq = mysql_query("select username `users` `user_id` = '".$eventq['user_id']."'");    while($player = mysql_fetch_assoc($rosterq)){     echo("         <tr>             <td>".$player['username']."</td>         </tr>     ");    } } 

use sub query kill first one.

select username `users` `user_id` in (   select user_id `users-events` event_id = 5 ) 

rest fine, looping on second result set should do. unless have large number of records, there should not considerable performance degradation use of in otherwise can optimize query.

5 example, use $id there correctly.


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 -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -