I have a webpage which sends a query to my MySQL database to retrieve information about my company's suppliers and echos the results (all fine so far). It then makes a second query to check if there are any known contacts associated with that supplier:
while ($row = mysqli_fetch_array($result)) {
$contact = $row["contact"];
echo $row["name"] . "<br>" . $row["category"] . "<br>" . "Telephone: " .
$row["telephone"] . "<br>" . "Fax: " . $row["fax"] . "<br>" .
$row["email"] . "<br>" . $row["address"] . "<br>" .
$row["postcode"] . "<br><br>" . "Contact: " .
$contact . "<br>";
$resultContact = mysqli_query($con,"SELECT * FROM contacts WHERE name =
'$contact'");
while($rowContact = mysqli_fetch_array($resultContact)) {
echo $rowContact["telephone"] . "<br>" . $rowContact["email"];
echo "<br>";
}
}
($row
is from the first query and works.) However, echo $rowContact["telephone"] . "<br>" . $rowContact["email"];
just prints whitespace.
Thanks
EDIT: if I use a string literal in the Where clause, it works as it should. However, I used variables in exactly the same way as I am now in the first query and that works! I am confused :(
EDIT 2: the first query: $result = mysqli_query($con,"SELECT * FROM suppliers WHERE LOWER(name) = LOWER('$searchText')");
EDIT 3: the result of doing var_dump($resultContact);
: object(mysqli_result)#3 (5) { ["current_field"]=> int(0) ["field_count"]=> int(4) ["lengths"]=> NULL ["num_rows"]=> int(0) ["type"]=> int(0) }
I'm guessing this means that the query is coming back with the table ok, but the Where clause isn't comparing the contact name as I want it to...