1 回答
TA贡献1942条经验 获得超3个赞
<?php
require_once 'databaseconn.php';
#To get connection
$mysqli = new mysqli($db_hostname, $db_username, $db_password,$db_database);
#To get array of names from my database
$stmt = $mysqli-> prepare('SELECT name FROM members WHERE id');
$stmt->execute();
$result = $stmt->get_result();
#To store result as array in variable $application_names
while ($row = $result->fetch_assoc()) {
$application_names[] = $row;
}
#To test if name exists
$name = "Jane";
$flatArr = [];
foreach ($member_names as $memberArr) {
if(isset($memberArr['name'])) {
$flatArr[] = $memberArr['name'];
}
}
if (in_array($name, $flatArr))
{
echo "Match found for: " . $name;
}
else
{
echo "Match not found for: " . $name;
}
?>
- 1 回答
- 0 关注
- 163 浏览
添加回答
举报