php中的格式,q是html穿过来的参数
$sql="SELECT * FROM zy WHERE name like '%".$q."%'";
一般格式
$sql="SELECT * FROM zy WHERE name like '%猫%'";
这样例如 name为 黑猫,黑猫警长的数据都会被查询到
完整php代码
<?php
$q =($_GET['q']);
echo "$q";
$con = mysqli_connect('rm-2ze19853tg90d442jao.mysql.rds.aliyuncs.com:3306','root','13821280093aA','ziyuan');
if (!$con) {
die('Could not connect: ' . mysqli_error($con));
}
$sql="SELECT * FROM zy WHERE name like '%".$q."%'";
$result = mysqli_query($con,$sql);
echo "<table>";
while($row = mysqli_fetch_array($result)) {
echo "<tr><th>CustomerID</th><td>" . $row['id'] . "</td></tr>";
echo "<tr><th>CompanyName</th><td>" . $row['name'] . "</td></tr>";
echo "<tr><th>ContactName</th><td>" . $row['show'] . "</td></tr>";
echo "<tr><th>link</th><td>" . $row['link2'] . "</td></tr>";
echo "<tr><th>link</th><td>" . $row['link3'] . "</td></tr>";
echo "<tr><th>link</th><td>" . $row['link'] . "</td></tr>";
}
echo "</table>";
mysqli_close($con);
?>