我正在尝试使用选取框来显示作业表中的所有数据,但尽管它已成功连接到数据库,但我无法显示任何内容。那么如何使用选取框显示数据?
<html>
<body>
<div class="box" STYLE="position:absolute; TOP:110px; LEFT:1100px;height: 470px;width : 200px;padding:10px;" >
<!-- STYLE="position:absolute; TOP:170px; LEFT:980px;height: 349px;width :360px;" -->
<u><font size="3" color="white">- Jobs may inters you :</font></u>
<br>
<marquee direction="up" scrollamount="2">
<p id="boxContent">
<script>
<?php
$conn = new Mysqli("localhost", "root", "", "ISNet");
if($conn->connect_error){
die("Connection failed:".$conn->connect_error);
}
$sql = "SELECT * FROM jobs";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
echo "<br> position - ". $row["position"]. "<br> company- ". $row["company"].
" <br> address -" . $row["Address"] ."<br> description - " . $row["description"] . " <br> mail -" . $row["mail"] .
"<br>";
echo "----------------------------------";
}
} else {
echo "0 results";
}
?>
</script></p>
</marquee>
</div>
</body>
</html>
最佳答案
这是您在选取框开始时所做的:
<marquee direction="up" scrollamount="2">
<p id="boxContent">
<script>
您打开一个脚本标签,这样您回显的所有内容都会在脚本标签内结束,并将被浏览器解释为 javascript。因此,您可能会在控制台和源代码中的文本中看到很多错误。
只需删除开头和结尾的脚本标签,您就会拥有一个非常酷的复古选框:-)
关于php - 如何在跑马灯中显示 mysql 数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48625845/