You need to use javascript for this.
In order to get the info out of the database and in to javascript, you need some PHP that will get the information and spit out a javascript array.
So you'd have something like this:
$things = array();
$result = mysql_query("select whatever from things") or die(mysql_error());
while ($row = mysql_fetch_row($result)) {
$things[] = $row[0];
}
echo "jsarray = [ ".implode(",", $things)." ];\n";
That will spit out a javascript array that you can then use in your javascript on the page. You'll need to modify it for whatever you're doing of course, but that should get you started.