I have very limited to zero knowledge about SQL or DBs, so apologies in advance.
I am attempting to make a table like structure within a webpage, a column for meal name, and a column for ingredients - it is also searchable via a button.
EDIT:
Thanks for all the replies, they have been most helpful. The error no longer happens, however now I get no results from the database, but no error.
include("inc/dbConn.php"); /////$db_conx
if(isset($_POST["search"])){
$searchq = $_POST["search"];
$sql ="
SELECT main_meal.name, ingred.name
FROM main_meal
JOIN meal_ingred on meal_ingred.meal_id = main_meal.id
JOIN ingred ON ingred.id = meal_ingred.ingred_id
WHERE ingred.name LIKE '%$searchq%'";
$results = $db_conx->query($sql);
var_dump($results);
if($results->num_rows){
while ($row =$results->fetch_object()){
echo "{$row->name} ({$row->name})<br>";
}
}
}
For clarification here is my structure:
(Sorry for external link, I dont have enough reputation to post images.)
http://i30.photobucket.com/albums/c340/Tyrage/Untitled-2_zpsc48126b3.png
The $results dumps:
object(mysqli_result)#2 (5) { ["current_field"]=> int(0) ["field_count"]=> int(2) ["lengths"]=> NULL ["num_rows"]=> int(0) ["type"]=> int(0) }
It is quite obvious I don't have a clue what I am doing, so any help is appreciated.
Thanks.