PHP MySQL Query from two different tables based on result from first query -
i have standard select query selects records products
table , display in table. need query run after based on result, in order field customers
table.
so example. query products
table shows user_id
field. need run sql query simultaneously in order user_name
customers
table.
$result = mysqli_query($con,"select * products (select eu_name customer $id_mobile = $id_mobile"); echo "<table border='1'> <tr> <th>user_id</th> <th>user_name</th> <th>selected_product</th> while($row = mysqli_fetch_array($result, mysqli_assoc)) echo "<td>" . $row['eu_name'] . "</td>"; echo "<td>" . $row['user_name'] . "</td>"; echo "<td>" . $row['selected_product'] . "</td>";
with given table structure
customers(user_id, user_name, user_email) products (product_id, product_name, user_id)
you can products associated customer as
select p.product_id,p.product_name,u.user_name,u.user_email products p inner join customers u on u.user_id = p.user_id
you can add condition additional filter of data.
Comments
Post a Comment