Jump to content

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]
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.