'stock' table >>
stock_id integer NOT NULL AUTO_INCREMENT,
modal varchar(40) NOT NULL DEFAULT "",
company varchar(40) NOT NULL DEFAULT "",
bike_number varchar(10) NOT NULL DEFAULT "",
lair_id integer NOT NULL DEFAULT 0,
PRIMARY KEY(stock_id)
'feature' table >>
feature_id integer NOT NULL AUTO_INCREMENT,
feature varchar(40) NOT NULL DEFAULT "",
primary key (feature_id)
'stock_feature' linking table >>
stock_id integer NOT NULL,
feature_id integer NOT NULL,
primary key(stock_id, feature_id)
I retrieved the stock_id using query1 and have it as $row['stock_id']. I want to display all the feature for this stock_id by saving the feature in array first.
Here is my code which is not working
$query2='SELECT feature FROM feature f JOIN stock_feature sf ON f.feature_id=sf.feature_id WHERE sf.stock_id='.$row['stock_id'];
$result2=mysqli_query($db, $query2) or die(mysqli_error($db));
if(mysqli_num_rows($result2)>0){
$features=array();
while($row2=mysqli_fetch_assoc($result2)){
$features[]=$row2['feature'];
}
echo '<td>' . implode (', ', $features) . '</td>';
}else{
echo '<td> No significant feature </td>';
}