在下面的代码中,当我搜索特定变量时,我有一个 php 代码,即我正在寻找一个以 b 开头的变量。所有以 b 开头的变量都在警报框中一一显示。但我想在一个警报中显示. 实际结果:一一显示警报
<?php
$search = (isset($_POST['search']) ? $_POST['search'] : null);
mysql_connect("localhost", "root", "") OR die (mysql_error());
mysql_select_db ("slseatapp") or die(mysql_error());
$query = "SELECT * FROM `coursemaster` WHERE `course_code` LIKE '%$search%' or `course_name` like '%$search%'";
$result = mysql_query($query) or die (mysql_error());
if($result)
{
while($row=mysql_fetch_row($result))
{
echo"<script>alert('ID=$row[0],COURSE CODE=$row[1],COURSE NAME=$row[2]');</script>";
}
}
else
{
echo "No result";
}
?>
<form action="coursemaster_view" method="post">
<center> SEARCH:<input type="text" name="search" placeholder="SEARCH"><br></center>
<center> <input type="submit" class="btn-success btn"></center>
</form>