Reputation: 150
I've tried everything but... marquee is showing in two lines but i want it on one line.
Here is my code:
<?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);
?>
Does anyone know the problem in my code?
Upvotes: 0
Views: 969
Reputation: 2330
Your code must be like this
<?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);
?>
Upvotes: 3
Reputation: 2509
Put this code out side of while loop, Reason its showing you twice cause, Your are returning two row from your query
echo "<style>";
echo "marquee { white-space: pre; }";
echo "</style>";
echo "<marquee>";
The last line echo "</marquee>";
after the while loop, and rest of the line above while loop
Upvotes: 0