我已经尝试了一切,但是......选框显示在两行中,但我希望它在一行上。
这是我的代码:
<?php
$con=mysqli_connect("localhost","Protected","Protected","Protected");// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT * FROM questions");
while($row = mysqli_fetch_array($result)) {
echo "<style>";
echo "marquee { white-space: pre; }";
echo "</style>";
echo "<marquee>";
echo '<span class="name">' . '•' . "<b>Naam:</b> " . $row['naam'] . "<b> Vraag:</b> " . $row['vraag'] . "</span>". "</marquee>";
}
mysqli_close($con);
?>
有人知道我的代码中的问题吗?
答案 0 :(得分:3)
您的代码必须像这样
<?php
$con=mysqli_connect("localhost","Protected","Protected","Protected");// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT * FROM questions");
echo "<style>";
echo "marquee { white-space: pre; }";
echo "</style>";
echo "<marquee>";
while($row = mysqli_fetch_array($result)) {
echo '<span class="name">' . '•' . "<b>Naam:</b> " . $row['naam'] . "<b> Vraag:</b> " . $row['vraag'] . "</span>";
}
echo "</marquee>";
mysqli_close($con);
?>
答案 1 :(得分:0)
将此代码放在while循环的一边,Reason显示两次原因,您从查询返回两行
echo "<style>";
echo "marquee { white-space: pre; }";
echo "</style>";
echo "<marquee>";
while循环后的最后一行echo "</marquee>";
,以及循环上面的其余行