Hi I am trying to do a join (left, inner, right, I'm not sure) and need some direction. I have 2 tables, merchants, and coupons. Here is an example of both:
merchant table
| merchantID | merchantName |
| 1 | Acme Corp |
coupons table
| merchantID | offer |
| 1 | buy 1 pizza get 1 free |
The result I am looking for is:
| mechantID | merchantName | offer |
| 1 | Acme Corp | buy 1 pizza get 1 free|
The code I wrote:
<? require_once('connections/connmts.php');
mysql_select_db($database_connmts, $connmts);
$query_rscoupons = "SELECT FROM coupons";
$rscoupons = mysql_query($query_rscoupons, $connmts) or die(mysql_error());
//get merchant info
mysql_select_db(mts, $connmts);
$query_merchants = "SELECT FROM merchant LEFT JOIN coupons ON coupons.merchantID=merchant.merchantID";
$rsmerchants = mysql_query($query_merchants, $connmts) or die(mysql_error());
// get= coupon info
while ($newArray = mysql_fetch_array($rscoupons)) {
$couponID = $newArray['couponID'];
$merchantID = $newArray['merchantID'];
$date = $newArray['experationDate'];
$offer = $newArray['offer'];
$active = $newArray['active'];
}
// print the results
print $couponID." ".$rsmerchants." ".$date." ".$offer." ".$active."<br>";
mysql_close($connmts);
?>
Gives me this :
1 Resource id #3 12/31/2004 none 1
?????
What is Resource id #3 ??
Thanks in advance,
Dmacman1962