Where and Limit Condition in php

The WHERE Clause is used to filter only those records that are fulfilled by a specific condition given by the user. in other words, the SQL WHERE clause is used to restrict the number of rows affected by a SELECT, UPDATE or DELETE query.

<?php

include('dbNew.php');

$q = "SELECT employer_id FROM ql_milestone WHERE project_id = $project_id LIMIT 1";
$result = $conn->query($q);

if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo "employer_id: " . $row["employer_id"]. "<br>";
}
}

?>

Leave a Reply