This question already has an answer here:
I've been fiddling with this for bit and tried a couple different ways to combine both SELECT FROM statements, but I can't get it to work where I can call on fields from two tables within the same database. It works find if I remove either one. I tried to combine them using UNION (not sure if that's the correct thing), but couldn't get it to work.
Here's what I got so far with them separated:
$id = $_POST['id'];
$edit = $db->prepare("SELECT * FROM contacts WHERE id = (?)");
$edit->bind_param('s', $id);
$edit->execute();
$edit->bind_result($id, $firstName, $lastName, $email, $phone, $category);
$categories = $db->prepare("SELECT * FROM category");
$categories->execute();
$categories->bind_result($cateid, $setcategory);
echo $firstName;
while ($categories->fetch()) {
echo $setcategory;
}
I'm new to all of this. I'd be grateful if someone could point me in the right direction. Thanks!
</div>