I have two data tables in a MySQL database as follows.
Customer Table data fields are Id, Name, Contact_Number, status, Customer_Id Items Table data fields are Id, Item_Name, Price. The foreign key is Customer_Id in the item table.
I created a form to save items. if I fill the form item table Customer_id had been saved as I was given.
**Then I need to show correctly selected item and that saved customer id's data in a web page table **
The page table fields are | Item Id | Customer Name | Contact No | Price |
I coded as follows.
<?php
require_once("../inc/conn.php");
$query = " select customer.*,item.* from customer,items WHERE status='1' ORDER BY id DESC LIMIT 5";
$result = mysqli_query($con,$query);
?>
<table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
<thead>
<tr>
<th> ID </th>
<th> Customer Name</th>
<th> Contact No</th>
<th> Price </th>
</tr>
</thead>
<tbody>
<tr>
<?php
while($row=mysqli_fetch_assoc($result))
{
$id = $row['id'];
$c_name = $row['Name'];
$contact_no1 = $row['Contact_Number'];
$contact_no2 = $row['Price'];
<tr>
<td><?php echo $id ?></td>
<td><?php echo $name?></td>
<td><?php echo $Contact_Number?></td>
<td><?php echo $Price?></td>
?>