lien entre deux tables
Posté : 29 janv. 2008, 17:13
J'ai deux tables
une table commandes
et l'autre est la table article_commande
je voulais que l'id_commande de la table article_commande soit égal à l'id de la table commande
voici mon code :
merci
une table commandes
Code : Tout sélectionner
CREATE TABLE commandes (
id tinyint(10) NOT NULL auto_increment,
id_membre tinyint(10) default '0',
`date` date NOT NULL default '0000-00-00',
heure time NOT NULL default '00:00:00',
PRIMARY KEY (id)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
Code : Tout sélectionner
CREATE TABLE article_commande (
id tinyint(10) NOT NULL auto_increment,
id_commandes tinyint(10) NOT NULL default '0',
designation text NOT NULL,
nom text NOT NULL,
qte tinyint(11) NOT NULL default '0',
PRIMARY KEY (id)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
voici mon code :
$sql="select id from commandes where id_membre='$id_membre'";
$req=mysql_query($sql);
$row = mysql_fetch_assoc($req);
$id_commandes= $row['id'];
mais j'ai un problème puisque le nombre que j'obtiens pour id_commande est inférieur de 1 à l'id de commandesmerci