我有一个学校数据库,我想这样当您在数据库中搜索现有数据时,它会在输入框旁边输出。因此,无需进入新页面。这是一个有什么:
<form action=" " method="post">
School's name: <input type="text" name="schoolname"> <br/>
<input type="submit" name="button" value="Search">
</form>
<?php
$school = $_POST['schoolname'];
$conn = mysql_connect("localhost", "root");
mysql_select_db("finalproject");
$sql = "select * from presentations where school like '%$school%'";
$result = mysql_query($sql, $conn) or die(mysql_error());
if ( mysql_num_rows($result) >0)
{
while ($newArray = mysql_fetch_array($result))
{
$school = $newArray['school'];
$date = $newArray['date'];
$place = $newArray['place'];
$time = $newArray['time'];
echo $school . ", " . $place . ", " . $date . ", " . $time . "<br />" ;
}
}
else
{
echo "Record not found";
}
mysql_close($conn);
?>
这是我以前用来链接到另一个页面的代码,在那里输出。但现在我只想在同一页面上输出它。我确实将一些代码从似乎不再有效的其他页面移了过来。PHP 位只输出: "0) { while ($newArray = mysql_fetch_array($result)) { $school = $newArray['school']; $date = $newArray['date']; $place = $newArray[ 'place']; $time = $newArray['time']; echo $school . ", " . $place .", " . $date .", " . $time ." " ; } } else { echo " Record not found"; } mysql_close($conn); ?>" 到我的页面输入下方。我对此真的很陌生,所以任何人的帮助将不胜感激。:D