hi i am making a program in php. it actualy involves two tables from database one is order and other product_details i want that when i select a order i get its product and quantity and respective to that product i find quantity of first raw material reqruired. and then multiply the quantity of 'order' and product table. i have written code its working and not giving me any error but value which it calculates is wrong my code is:


  $order= ($_POST['order_id']);
  $query= " SELECT * FROM `order` WHERE Order_ID='$order'";
  if ($result)
     if ($row['order_status']=='pending')
	 echo "$total_quantity";
	 $query1="SELECT * FROM product_details WHERE product_name='$product'";
	  $result1=mysql_query($query1) or die(mysql_error());

		  if ($result1)	 
		  echo "$mat1_req";
		  echo "second query failed";
	 echo "This order is in process now";
	echo "No record found";

What exactly is the output you expect. Try giving a detailed example.

Sidenote: Am not sure how your table structures are, but you should be able to use a single join query, so you won't have to query twice.

can u please tell me how the join statement works? i know the syntax and all that but what is the purpose of that

It's to connect the order with the product details, so you have all info you need in one query result. You could let that query do your multiplication as well. If you use this a lot, you can turn that query into a view. My personal opinion is that a view is much more managable than a query with calculations in source code.

yeah i will try to learn more about views as well.
now i m facing another problem
when i write this code:

$query2="SELECT quantity FROM rpms WHERE product_name='$raw_material1'";
		  $result2=mysql_query($query2) or die(mysql_error());
		  if ($result2)
			echo "$quantity2";

it gives the following error
Notice: Undefined index: quantity in C:\wamp\www\pras\calculation.php on line 45

You get that notice when you try to use an array with key 'quantity', but it is not set. A possible cause is that your query returns no results. There is no check for that.