How to show username not id?

how can i join the user id from list and show the username from users table
into this script i dont know how joins work i have looked and try
to do it in this but it confusing me


         $sql = "SELECT list.*,count(username) as faucet  FROM list GROUP BY username";
         $result = mysqli_query($link, $sql);
         if( $result )    
         while($user = mysqli_fetch_assoc($result)) {
               <table class="table table-striped" id="faucetlist" width="100%" cellspacing="0">
                    <th><center>Last updated</center></th>
                <td><center><?php echo $user["username"]; ?></center></td>   
                 <td><center><?php echo date('l jS F Y' , strtotime($user['Published']));?></center></td>              
                <td><center><?php echo date('h:i A' , strtotime($user['last_update']));?> </center></td>   
                 <td><center></center><?php echo $user['faucet'];   ?></td>   

           <?php } ?>

You really want to build a table for each database result?

No i just need the username from users table to go to where the 1 and 2 is so 1 admin 2 user

How about we start with taking a look at your database. Post an SQL dump of your DB with a few sample records.


theres 300 in my database so i cant do an SQL dump sorry

Pictures are for hanging on the wall and they dont import to a DB structure and I have no idea what table that is. Just post the table Sql. I can add some fake data.

EDIT: You just need a basic JOIN on the two tables joining on the user id column of the users table and the username column of the other table.

what one? the list or the users?

Both, or you could just read my edit in the previous post.

but how can i do it as i read up on google and i cant understand it

Then give me what I asked for. The easier you make it to help you the better help you will get.

Something like this…

SELECT u.username, l.sumcolumn
FROM users u
INNER JOIN list l ON l.username=u.user_id;

i cant do it heres the zip file off sql anyway

Modify to suit your needs

	users u
	INNER JOIN list l ON l.username =

shows me blank


         $sql = "SELECT
	l.faucet_name,,count(username) as faucet 
	users u
	INNER JOIN list l ON l.username =  GROUP BY l.username";
         $result = mysqli_query($link, $sql);
         if( $result )    
         while($user = mysqli_fetch_assoc($result)) {
        ?> ```

Never mind now i got it to work thank you @benanamen

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.