0

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

2
Contributors
4
Replies
5
Views
5 Years
Discussion Span
Last Post by cereal
0

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'

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.