hey m making a website which use to tel the daily report. there are many other functionalities as well.
i have three tables concerned with this problem
1. shift
2. molding section
3. intermediate store
on the basis of date and shift num, shift ids are assigned now i want that when user enter the date corresponding 3 shift id are obtained and for each of them the report is generated and displayed. i have written this program but it only gives the output for one shift not all three. as three shifts are there in a day.

<?php
$con=mysql_connect("localhost","root","");
 
	mysql_select_db("pras2");
	
	$date= $_POST['date'];
	
	$query="SELECT shift_id  FROM shift WHERE date='$date'";
	
	 $result=mysql_query($query);
	 
 
  if ($result)
  {
  
  
  $row=mysql_fetch_row($result);


   // $shift_id=$row['shift_id'];
  


  $query1="SELECT molding_section.shift_id, molding_section.machine_name, molding_section.product_name, molding_section.item1,molding_section.num1,molding_section.item2,molding_section.num2,   intermediate_store.quantity_sorted, quantity_rejected,reason_of_rejection FROM molding_section, intermediate_store 
         WHERE molding_section.shift_id = intermediate_store.shift_id AND intermediate_store.shift_id='$row' AND molding_section.product_name = intermediate_store.product";
		
		$result1=mysql_query($query1) or die(mysql_error());
		if ($result1)
		{
		echo '<table width=600 border=1>
 
<tr><th>Shift ID</th>
<th>Machine name</th>
<th>Product name</th>
<th>Item 1</th>
<th>Quantity</th>
<th>Item 2</th>
<th>Quantity</th>
<th>Quantity produced</th>
<th>Quantity sorted</th>
<th>Quantity rejected</th>
<th>Reason for rejection</th>

</tr>';
		while ($get_info = mysql_fetch_row($result1))
{
print "<tr>\n";
 
foreach ($get_info as $field)
 
print "\t<td>$field</td>\n";
 
print "</tr>\n";
}print "</table>\n";

}
}
?>

Recommended Answers

All 2 Replies

You will have to use a while for shift, just like you did for the second query.

i tried that but still it didnot get the correct shift ids it takes 0 value and display its result
i wrote it as:

$query="SELECT shift_id  FROM shift WHERE date='$date'";
	
	 $result=mysql_query($query);
	 
 
  if ($result)
  {
  
  
  
 while ($row=mysql_fetch_row($result))

{
   // $shift_id=$row['shift_id'];
 $shift_id=$row['shift_id'];
   // $shift_id=$row['shift_id'];
  


  $query1="SELECT molding_section.shift_id, molding_section.machine_name, molding_section.product_name, molding_section.item1,molding_section.num1,molding_section.item2,molding_section.num2,   intermediate_store.quantity_sorted, quantity_rejected,reason_of_rejection FROM molding_section, intermediate_store 
         WHERE molding_section.shift_id = intermediate_store.shift_id AND intermediate_store.shift_id='$shift_id' AND molding_section.product_name = intermediate_store.product";
		
		$result1=mysql_query($query1) or die(mysql_error());
		if ($result1)
		{
		echo '<table width=600 border=1>
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.