Hi there,
I am trying to inner join two tables on the same id, which is " recipeid"
my tables are :
CREATE TABLE recipes (
recipeid int(10) unsigned NOT NULL default '0',
title varchar(255) default NULL,
recipe text,
userid int(10) unsigned default NULL,
rating int(10) unsigned default '0',
categoryid int(10) unsigned default NULL,
date varchar(20) NOT NULL default '',
story text,
hits int(10) unsigned default '0',
status char(1) default 'W',
PRIMARY KEY (recipeid),
UNIQUE KEY recipieid (recipeid),
KEY recipieid_2 (recipeid)
) TYPE=MyISAM
CREATE TABLE ingredients (
recipeid int(10) unsigned NOT NULL default '0',
ingredient varchar(255) NOT NULL default ''
) TYPE=MyISAM;
And my code is :
<?php
if (isset($_GET["id"]) && $_GET["id"] > 0) {
mysql_connect("****","****","****");
mysql_select_db("******");
include ('class.ezpdf.php');
$pdf =& new Cezpdf();
$pdf->selectFont('./fonts/Helvetica');
$pdf->ezText('Recipe Collection',14);
$pdf->ezText('© 2005 Recipe Collection, .',10);
$pdf->ezText('',12);
$result=mysql_query("SELECT * FROM recipes LEFT JOIN ingredients ON (recipes.recipeid = ingredients.recipeid) WHERE recipeid='$_GET[id]'");
$i=0;
while( $row=mysql_fetch_array($result) )
{
$data[$i]=array('title'=>$row['title'],'recipe'=>$row['recipe'],'ingredient'=>$row['ingredient']);
$i++;
}
$pdf->ezTable($data,"","",array('xPos'=>'left','xOrientation'=>'right','width'=>500));
$pdf->ezStream();
exit;
}
?>
This file is called pdf.php, ( generates pdf file from mysql) so once i execute this file in this way pdf.php?id=1, that should show records from recipes based on id=1, and in that insert the record from ingredients called ingredients
Can any1 help ?
Thank you,
Rutin