用错误404将我射到/index.php。我不希望它导航到另一页,只需将结果显示在表中即可。
我不太确定自己在做什么错,我刚启动php,并一直使用w3导航语法。我设法制作了一个可以显示整个表格的插件,但是现在我试图使用一种形式来搜索表格并显示结果。
...
if( isset($_GET['submit']) ){
$ssterm = $_POST["name"];
$query = "SELECT ID, Retailer, City, State, Contact, Address1, Address2, Country, Zip, Email, Website FROM Stores WHERE Retailer LIKE '%" . $rssterm . "%' OR City LIKE '%" . $ssterm ."%'";
$result = $conn->query($query);
if($result->num_rows > 0){
echo "<table>
<tr>
<th>ID</th>
<th>Retailer</th>
<th>City</th>
<th>State</th>
<th>Contact</th>
<th>Address1</th>
<th>Address2</th>
<th>Country</th>
<th>Zip</th>
<th>Email</th>
<th>Website</th>
</tr>";
while($row = $result->fetch_assoc()){ //Creates a loop to loop through results
echo "<tr><td>" . $row['ID'] . "</td><td>" . $row['Retailer'] . "</td><td>" . $row['City'] . "</td><td>" . $row['State'] . "</td><td>" .
$row['Contact'] . "</td><td>" . $row['Address1'] . "</td><td>" . $row['Address2'] . "</td><td>" . $row['Country'] . "</td><td>" . $row['Zip'] .
"</td><td>" . $row['Email'] . "</td><td>" . $row['Website'] . "</td></tr>"; //$row['index'] the index here is a field name
}
echo "</table>"; //Close the table in HTML
}
else {
echo "No Results Found...";
}
}
?>
<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" id="searchform">
<input type="text" name="name">
<input type="submit" name="submit" value="search">
</form>
<?php
$conn->close(); //Make sure to close out the database connection
} // end of a shortcode brace
?>
我认为这肯定可以工作,但是它只是将我射向/index.php并出现错误404。我不希望它导航到另一页,只在表中显示结果。我在wordpress网站上使用它,并作为一个使用简码的插件将其实现到页面中。