简体   繁体   English

PHP 不显示在 HTML 页面上

[英]PHP does not display on HTML page

I'm trying to make a dropdown list of genres that a user can select and then view all the series in that genre.我正在尝试制作一个用户可以选择的流派下拉列表,然后查看该流派中的所有系列。 Here is my HTML code这是我的 HTML 代码

<td><p>Select a Genre to View</p>

<form id=”form1” method=”post” action=”view_process.php”>
</br>
<?php include("dropdown.php"); ?>

</br>
<input style="display:none" type="submit" id="sub"/>
</form>

And then here is my PHP for the drop down:然后这是我用于下拉菜单的 PHP:

<?php
require_once 'login_sec217.php'; 
$db_server = mysqli_connect($db_hostname, $db_username, $db_password, 
$db_database);
if (!$db_server) die("Unable to connect to MySQL: " . 
mysqli_error($db_server));

$query = "SELECT genre_name FROM genres;";
$results = mysqli_query($db_server, $query);
if(!$results)
die("Query Error: "  . mysqli_error($db_server));
else {
echo "<select id=\"opt\" name=\"name\"onchange=\"showButton()\">";
echo "<option value=\"none\">please select</option>";
while($row=mysqli_fetch_assoc($results))
{
foreach($row as $key=>$value) ${$key}=$value;
echo "<option value=\"&genre_name\">$genre_name</option>";
}
echo "</select>";
}
?>

and for my table of the results:对于我的结果表:

<?php
foreach($_POST as $key=>$value) ${key}=$value;
require_once 'login_sec217.php'; 
$db_server = mysqli_connect($db_hostname, $db_username, $db_password, 
$db_database);
if (!$db_server) die("Unable to connect to MySQL: " . 
mysqli_error($db_server));
$query = "SELECT s.series_title, s.series_author_last, s.series_author_first 
FROM series s INNER JOIN 
genrelink.l ON s.series_id = l.series_id INNER JOIN genres g ON g.genre_id = 
l.genre_id WHERE g.genre_name 
= '$name';";
$result = mysqli_query($db_server,$query);
?>
<table width="100%">
<tr>
<th>Title</th>
<th>Author Last Name</th>
<th>Author First Name</th>
</tr>
<tr>
<?php
$row = mysqli_fetch_row($result);
echo "<td>$row[0]</td>";
echo "<td>$row[1]</td>";
echo "<td>$row[2]</td>";
?>
</tr>
</table>

The PHP seems to operate perfectly standing alone, but when I put them on the webpage...nothing appears. PHP 似乎完全独立运行,但是当我将它们放在网页上时......什么都没有出现。 The database is connecting but something with the insertion into the HTML page is screwing with this?数据库正在连接,但插入到 HTML 页面的某些东西正在搞砸? Any thoughts would be awesome.任何想法都会很棒。

change your code like this像这样改变你的代码

<tr><td><input type="checkbox" name="genre[]" value="1" />Action </td>
<td><input type="checkbox" name="genre[]" value="2" />Adventure </td></tr>
<tr><td><input type="checkbox" name="genre[]" value="3" />Comedy</td>
<td><input type="checkbox" name="genre[]" value="4" />Coming of Age</td></tr>
<tr><td><input type="checkbox" name="genre[]" value="5" />Dark fantasy</td>
<td><input type="checkbox" name="genre[]" value="6" />Drama</td></tr>
<tr><td><input type="checkbox" name="genre[]" value="7" />Fantasy</td>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM