Jump to content

Marquee Issue - Display Entire Database


joe904

Recommended Posts

Hey Guys,

 

I am trying to fix a PHP page that I am coding for my job. Basically the functionality that I am looking for is a Marquee (Yes I understand the Marquee is done away with in HTML5. I haven't learned to use CSS instead yet) function where the names that I have in my database will scroll from bottom to top in the center of the page. I am a teacher and I am trying to set up a point system to display the points that my kids have earned. I have a MySQL database that has a few fields, such as student ID's, Names, etc. I want to connect my database and have the names and associating information scroll up one after the other on my website. I have some code that I found it online but it didi not work correctly. When it displayed, the entire database showed at once and then disappeared instead of scrolling one at a time. Yes I am a newby at this, so please have patience with me. I have searched online for an answer, and have not been able to find one. So I sdecided to try this forum. Any help is greatly appreciated.


<?php

$scrolling="true"; //Define if text is scrolling or Still

//Config
$db_host="localhost";
$db_name="swap";
$db_user="root";
$db_pass="pass";



// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL. Make sure to edit the config.php file: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT * FROM students ORDER BY studentId ASC ");
while($swap = mysqli_fetch_array($result))
{
if ($scrolling == "true"){
//Scrolling Text
?>

<html> <h1 class="marquee"><span><b><?php echo $swap['studentId'];?> <?php echo $swap['first_name'];?></b><?php echo $swap['last_name']; ?><</html>

<?php }
else { //Not Scrolling Text
?><b><?php
echo $swap['studentId'];
?>
</b>:
<?php echo $swap['last_name'];
}
}

?>

Edited by cyberRobot
adjusted the font size
Link to comment
Share on other sites

First you have to fix your HTML markup.

 

Taking what you have there as a reference, you need to create this:

<html>
<body>

<div class="marquee">
	<h1>ID: NAME</h1>
	<h1>ID: NAME</h1>
	<h1>ID: NAME</h1>
	...
</div>

</body>
</html>
Can you do that? Note that the only part of that HTML that is being repeated (ie, needs to be in a loop) is the H1s. Everything else is plain HTML around it.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.