Jump to content

INNER JOIN display info on the web


Pain

Recommended Posts

Hello.

 

I am trying to display info from two tables with this code.

 

<?php

$query = mysql_query("SELECT users.username, users2.username FROM users INNER JOIN users2 ON users.id = users2.id");
$numrows = mysql_num_rows($query);

if ($numrows != 0)

{
while ($row = mysql_fetch_assoc($query))
{
	$username = $row['username'];
	echo $username . "<br />";

}

}


?>

 

However it displays info only from one db (users). I suppose there's something wrong with

<?php
...
while ($row = mysql_fetch_assoc($query))

{
	$username = $row['username'];
	echo $username . "<br />";

}
...
?>

 

Any help will be appreciated. Thank you.

Link to comment
https://forums.phpfreaks.com/topic/251556-inner-join-display-info-on-the-web/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.