答案 0 :(得分:1)
起初,您没有为您的:first_name
令牌提供适当的值
// Let's say value to match = $_POST['first_name']
$query = $db->query("SELECT * FROM people WHERE first_name = :first_name");
$statement = $db->prepare($query);
// Specify value to match in the `execute` call
$statement->execute(array(':first_name' => $_POST['first_name']));
//Now try this to confirm if the result is fetched
if ($statement->fetch())
{
echo "First name Exist";
}
//else it doesn't exist fetch!
else
{
$query = "INSERT INTO people (first_name, last_name) VALUES (:first_name, :last_name)";
$statement = $db->prepare($query);
for($count = 0; $count<count($_POST['hidden_first_name']); $count++)
{
$data = array(
':first_name' => $_POST['hidden_first_name'][$count],
':last_name' => $_POST['hidden_last_name'][$count]
);
$statement->execute($data);
}
}