Jump to content

displaying records in marquee


mrjameer

Recommended Posts

hi,

i have one mysql table called employee.its fields are as follows
id--name
1--abc
2---cbv
3--edr
.i want to display the all names from db in html marquee.when i try to print all values it prints only last value in marquee.how to do this.any of your help will be appreciated

thanks
mrjameer

Link to comment
https://forums.phpfreaks.com/topic/32568-displaying-records-in-marquee/
Share on other sites

Get all the names in an array when you get them out of the database then use the implode function to convert them in to one big string, example:

[code=php:0]// connect to mysql here

// the query:
// select all the names from the employee table
$qry = "SELECT name FROM employee";
$result = mysql_query($qry);

// put the names into an array
while($row = mysql_fetch_assoc($result))
{
    // our array will be called names
    $names[] = $row['name'];
}

// now we implode the array into a string:
// format will be the following:
// name1, names2, name3, namex
$namesList = implode(', ', $names);

// print the HTML marquee:
echo <<<HTML
<marquee behavior="scroll">Our employee's: {$nameList}</marquee>
HTML;[/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.