如何使用许多技能参数进行多重搜索??????
Microsoft Windows NT 10.0.10240.0
参数$ pSkills是一个数组
public function searchBySkills($pSkills){
$requete = $this->pdo->prepare("SELECT * FROM candidat WHERE skillsCandidat LIKE :skillsCandidat ");
$requete->bindValue(':skillsCandidat', '%'.$pSkills.'%', PDO::PARAM_STR);
$requete->execute();
$tab = $requete->fetchAll(PDO::FETCH_ASSOC);
$this->listCandidat = array();
foreach ($tab as $row) {
$candidat = new Candidat();
$candidat->fromPost($row);
//var_dump($row);
array_push($this->listCandidat, $candidat);
}
}
我曾经这样做过:
array (size=2)
0 => string 'developper' (length=10)
1 => string 'designer' (length=8)
还有其他方法吗? 在此先感谢您的帮助!
答案 0 :(得分:0)
<?php
$name = trim($_POST['name']);
$lastname = trim($_POST['lastname']);
$email = $_POST['email'];
$comments = $_POST['comments'];
$site_owners_email = 'info@inperfection.nl'; // Replace this with your own email address
$site_owners_name = 'CloudMe'; // replace with your name
if (strlen($name) < 2) {
$error['name'] = "Please enter your name";
}
if (strlen($lastname) < 2) {
$error['lastname'] = "Trolololololololo.";
}
if (!preg_match('/^[a-z0-9&\'\.\-_\+]+@[a-z0-9\-]+\.([a-z0-9\-]+\.)*+[a-z]{2}/is', $email)) {
$error['email'] = "Please enter a valid email address";
}
if (strlen($comments) < 4) {
$error['comments'] = "Please leave a comment.";
}
if (!$error) {
require_once('phpMailer/class.phpmailer.php');
$mail = new PHPMailer();
$mail->From = $email;
$mail->Subject = "Contact Form";
$mail->AddAddress($site_owners_email, $site_owners_name);
$mail->Body = "Naam :$name Achternaam:$lastname Email:$email Motivatie:$comments";
$mail->Send();
echo "<div data-alert class='alert-box success'>Thanks " . $lastname . ". Your message has been sent.<a href='#' class='close' onclick='clearForms()'>×</a></div>";
} # end if no error
else {
$response = (isset($error['name'])) ? "<div class='alert-box alert'>" . $error['name'] . "</div> \n" : null;
$response = (isset($error['lastname'])) ? "<div class='alert-box alert'>" . $error['lastname'] . "</div> \n" : null;
$response .= (isset($error['email'])) ? "<div class='alert-box alert'>" . $error['email'] . "</div> \n" : null;
$response .= (isset($error['comments'])) ? "<div class='alert-box alert'>" . $error['comments'] . "</div>" : null;
echo $response;
} # end if there was an error sending
?>