Click here to Skip to main content
15,887,027 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
<?php
     include("keselamatan.php");
     include("sambungan.php");
     include("penjual_menu.php");
?>

<link rel="stylesheet" href="asenarai.css">
<link rel="stylesheet" href="abutton.css">

<table>
	 <tr>
	 	  <th>ID Product</th>
	 	  <th>ID Model</th>
	 	  <th>Model Name</th>
	 	  <th>Picture</th>
	 	  <th>Price</th>
	 	  <th>Processor</th>
	 	  <th>RAM</th>
	 	  <th>Storage</th>
	 	  <th colspan="3">Note</th>
	 </tr>
      
     <?php    
          echo"<caption>LIST OF PRODUCT $tajuk</caption>";


          $sql = "select * from produk ".$syarat;
          $result = mysqli_query($sambungan,$sql);
          while($produk = mysqli_fetch_array($result)) {
          	    $IDProduk = $produk["IDProduk"];
          	    echo "<tr><td>$produk[IDProduk]</td>
          	    	 <td>$produk[IDModel]</td>
          	    	 <td><img width= 100 src='imej/$produk[gambar]'></td>
          	    	 <td>RM $produk[Harga]</td>
          	    	 <td>
          	    	 	 <a href='produk_update.php?IDProduk=$IDProduk'title='update'>
          	    	 	 	   <img src='imej/update.png'>
          	    	 	 </a>
          	    	 </td>
          	    	 <td>
          	    	 	 <a href='javascript:padam(\"\");'title='delete'>
          	    	 	       <img src='imej/delete.png'>
          	    	 	 </a>
          	    	 </td>
          	    	 <td>
          	    	 	 <a href='produk_maklumat.php?IDProduk=$IDProduk'title='maklumat'>
          	    	 	 	   <img src='imej/info2.png'>
          	    	 	 </a>
          	    	 </td>
          	    </tr>";
          }
    ?>
</table>
<center><button class="cetak" onclick="window.print()">Print</button></center>

<script>
      function padam(id)  {
      	    if (confirm("Do you want to delete this product?") == true){
      	    	   window.location = "produk_delete.php?IDProduk=" + id;
      	    }
      }
</script>


What I have tried:

In fact, the data I want to show comes from two different tables in the same database, which are produk and model.
produk (IDProduk, IDModel, Harga)
model (IDModel, NamaModel, Processor, RAM, Storage)

# Harga = Price
Posted
Updated 21-Jul-23 21:13pm

1 solution

Use a JOIN: SQL Joins[^] - they are what SQL is good at, and why it's known as a "relational database" system.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900