if($id=$customers_custnum) {
this will always evaluate to TRUE.
do you mean:
if($id==$customers_custnum) {
that may solve your problem.
= is the assignment operator (i.e. make left side equal to right side).
== is the comparison operator (i.e. check to see if the left side equals the right side)
also do you need to do the query on both tables like this:
$query = "SELECT * FROM orders, customers WHERE orders_custnum = '$id'";
you may be better off with a data structure where cutnum is stored in the orders table and then just:
$query = "SELECT * FROM orders WHERE orders_custnum = '$id'";
would work