Hey guys,
I need some help with selecting 2 Tables from a MySQL database. Can anyone help.

Currently I am using this, and I want it to be able to select from another table called Admin and Display the Admins under admins in my table.

<?php

$host=""; // Host name 
$username=""; // Mysql username 
$password=""; // Mysql password 
$db_name=""; // Database name 
$tbl_name=""; // Table name

// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");

// select record from mysql 
$sql="SELECT * FROM $tbl_name";
$result=mysql_query($sql);
?>

<table width="400px" border="2" cellspacing="3" cellpadding="5">
<tr>
<td><table width="400px" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<td col="2"
</tr>
<tr>
<td align="left" bgcolor="#FFFFFF"><strong>Normal Users</strong></td>
<td align="left" bgcolor="#FFFFFF"><strong>Admin Users</strong></td>
</tr>
<?php
while($rows=mysql_fetch_array($result)){
?>
<tr>
<td bgcolor="#FFFFFF"><? echo $rows['Username']; ?></td>
<td bgcolor="#FFFFFF"><? echo $rows['Username']; ?></td>
</tr>
<?
// close while loop 
}
// close connection; 
mysql_close();
?> 
</table>

Can someone Please help. Thanks in advance :)

If you want a separate read of another table, then define the select statement and use a mysql query with another variable as in:

$result2=mysql_query($sql);

In the subsequent code for that query, you will refer to $results instead of $result.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.