0

I have two tables called users and vm_tables. Now I am displaying data from users as below.

 $sel_query="Select * from users where account_id=".$_SESSION['admin_id'];

<td align="left"><?php echo $row["username"]; ?></td>
<td align="left"><?php echo $row["email_address"]; ?></td>

I would like to display data from vm_details also in same table.

Can anyone help me how to merge two tables data please.

Abdulla Nilam
  • 36,589
  • 17
  • 64
  • 85
Keerthi
  • 13
  • 7

3 Answers3

0

One way is to fetch data from 2 tables in 2 separate arrays and merge the arrays into one using array_merge or array_combine functions

0

you can create single table using JOIN and get both table data together (for this you have to have foreign key with ur second table) or use 2 sql_query arrays n display in one table both are possible.

0

you could use join

Select * from users u
LEFT JOIN vm_details v ON v.common_field=u.common_field
where u.account_id=".$_SESSION['admin_id']

whereas common_field is identical column on both table.

Tigris
  • 86
  • 1
  • 10