hi m using php n mysql
m trying to merge two tables of same database and then print them but somehow it is not working
it gives me the error
my code is

<?php
session_start();
print_r($_POST);

$con=mysql_connect("localhost","root","");
 
	mysql_select_db("pras2",$con);
 
  $date= $_POST['date'];

  $shift_num=$_POST['num'];
  
  $query="SELECT shift_id  FROM shift WHERE shift_no='$shift_num' AND date='$date'";
  $result=mysql_query($query);
  if ($result)
  {
  $row=mysql_fetch_assoc($result);
  $shift_id=$row['shift_id'];
  
  echo $shift_id;
  }
  
  $query1="SELECT *molding_section.machine_name, intermediate_store.product  FROM molding_section, intermediate_store 
         WHERE shift_id='$shift_id'";
		
		$result1=mysql_query($query1) or die(mysql_error());
		if ($result1)
		{
		while ($get_info = mysql_fetch_row($result1))
{
print "<tr>\n";

foreach ($get_info as $field)

print "\t<td>$field</td>\n";

print "</tr>\n";
}
}

  ?>

and error is

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'molding_section.machine_name, intermediate_store.product FROM molding_section, ' at line 1

but i cannot figure out the error

Remove the asterisk, bye :)

now this is the error how can i remove it

now this is the error
Column 'shift_id' in where clause is ambiguous

Do you have shift_id in both tables molding_section and intermediate_store? If yes, you need to change the where clause to: WHERE molding_section.shift_id='$shift_id' AND intermediate_store.shift_id='$shift_id'

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.