-1

I have problem to echo from two tables from the database. How to select two tables from database with has condition?

<?php session_start(); 
  $con=mysql_connect("localhost","root","");
  $db=mysql_select_db("fyp2", $con);  
  $username=$_SESSION['username'];   
  $query="SELECT * FROM customer WHERE username='$username'";
  $result=mysql_query($query);      
  $row=mysql_fetch_array($result);  
?>

In this situation, only one table can display, another table that i has insert it display no output.

annazie
  • 1
  • 1

1 Answers1

0

** Please implement that query **

<? include ("conn.php");
   $sql = "SELECT p.id,
                  p.name,
                  ps.name AS size_name
             FROM PRODUCT p
             JOIN PRODUCT_SIZES ps ON ps.size_id = p.size_id";
   $result = mysql_query($sql, $connection) or die(mysql_error());
   while($row = mysql_fetch_array($result)) {
?>
<tr>
  <td><? echo $row['id']; ?></td>
  <td><? echo $row['name']; ?></td>
  <td><? echo $row['size_name']; ?></td> 
</tr>
<? } ?>
Nims Patel
  • 1,048
  • 9
  • 19
  • Queries' fine, but please never ever use MySQL_ again, either use PDO/MySQLi_, MySQL library is deprecated and a security risk especially on the internet we live on today... – DevionNL Nov 21 '17 at 09:23
  • 1
    Yes i know but its answer for how to develop query. you can try that query with PDO or MySQLi. – Nims Patel Nov 21 '17 at 09:32