Currently I'm getting a single row from a single table and returning that to be processed by JS:
$sql = "SELECT * FROM labs WHERE lab_id = $lab_id";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
// send the data encoded as JSON
echo json_encode($row);
But now I need to add some data from another table. The "labs" table has a "lab_model_id" column which is an int. I need to use that "lab_model_id" to get "lab_model_name" from "lab_models".
1) How do I pull out the "lab_model_id" in my php to perform the second query?
2) Can I add the second result to the first before returning?