我在搜索由空格(manish pandey)組成的字符串時遇到問題。 PHP腳本只用於搜索(manish)而不是全名(manish pandey)。
我使用這裏得到的功能:
image,image2php腳本用於搜索字符串中包含空格的字符串
<!doctype html>
<html lang="en-US">
<head>
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset="UTF-8">
</head>
<body>
<?php
/*
Attempt MySQL server connection. Assuming you are running MySQL
server with default setting (user 'root' with no password)
*/
$link = mysqli_connect("localhost", "root", "root123", "sample");
// Check connection
if($link === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}
// Attempt select query execution
$sql = "SELECT * FROM qcdataa1 Where project_id='".$_GET['pid']."'";
if($result = mysqli_query($link, $sql)){
if(mysqli_num_rows($result) > 0){
echo "<table>";
echo "<tr>";
echo "<th>sno</th>";
echo "<th>project_id</th>";
echo "<th>project_name</th>";
echo "<th>application</th>";
echo "<th>investigator</th>";
echo "<th>created_by</th>";
echo "<th>creation_date</th>";
echo "<th>last_modified</th>";
echo "</tr>";
while($row = mysqli_fetch_array($result)){
echo "<tr>";
echo "<td>" .$row['sno']. "</td>";
echo "<td>" .$row['project_id'] . "</td>";
echo "<td>" .$row['project_name']. "</td>";
echo "<td>" .$row['application']. "</td>";
echo "<td><a href=fetchi2.php?iid=" .$row['investigator'].">" .$row['investigator']."</a></td>";
echo "<td>" .$row['created_by']. "</td>";
echo "<td>" .$row['creation_date']. "</td>";
echo "<td>" .$row['last_modified']. "</td>";
echo "</tr>";
}
echo "</table>";
// Close result set
mysqli_free_result($result);
} else{
echo "No records matching your query were found.";
}
} else{
echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}
// Close connection
mysqli_close($link);
?>
</body>
</html>
<!doctype html>
<html lang="en-US">
<head>
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset="UTF-8">
</head>
<body>
<?php
/*
Attempt MySQL server connection. Assuming you are running MySQL
server with default setting (user 'root' with no password)
*/
$link = mysqli_connect("localhost", "root", "root123", "sample");
// Check connection
if($link === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}
// Attempt select query execution
echo $_GET['iid'];
$sql = "SELECT * FROM qcdataa2 Where first_name='".$_GET['iid']."'";
if($result = mysqli_query($link, $sql)){
if(mysqli_num_rows($result) > 0){
echo "<table>";
echo "<tr>";
echo "<th>sno</th>";
echo "<th>first_name</th>";
echo "<th>last_name</th>";
echo "<th>userid</th>";
echo "<th>password</th>";
echo "<th>emailid</th>";
echo "<th>creation_date</th>";
echo "<th>last_modified</th>";
echo "</tr>";
while($row = mysqli_fetch_array($result)){
echo "<tr>";
echo "<td>" .$row['sno']. "</td>";
echo "<td>" .$row['first_name'] . "</td>";
echo "<td>" .$row['last_name']. "</td>";
echo "<td>" .$row['userid']. "</td>";
echo "<td>" .$row['password']. "</td>";
echo "<td>" .$row['emailid']. "</td>";
echo "<td>" .$row['creation_date']. "</td>";
echo "<td>" .$row['last_modified']. "</td>";
echo "</tr>";
}
echo "</table>";
// Close result set
mysqli_free_result($result);
} else{
echo "No records matching your query were found.";
}
} else{
echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}
// Close connection
mysqli_close($link);
?>
</body>
</html>
在SQL 使用'LIKE'哥哥解碼'SELECT * FROM qcdataa1 FIRST_NAME哪裏像' %「。$ _ GET ['iid']。」%'' –
它不工作bro – vinod
我希望它在first_name應該鏈接調查員列 – vinod