Forums
This topic is locked
marquee to take data from database
Posted 21 Nov 2006 12:18:03
1
has voted
21 Nov 2006 12:18:03 sally bierton posted:
hi can anyone help please..i have a script for a marquee..but what i would like is for the values to be accessed from a mysql database with just one field "news"thanks in advance if anyone can help.
<script language="JavaScript" ></script>
<html xmlns="www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>newsbar</title>
<style type="text/css">
<!--
a:link {
color: ff0000;
}
a:visited {
color: ff0000;
}
a:active {
color: ff0000;
}
body,td,th {
font-family: veranda;
font-size: small;
color: 000080;
}
body {
background-color: #D6DFF7;
}
a:hover {
color: ff0000;
}
-->
</style></head>
<body
<td width="1" bgcolor="#fffFF"></td>
<td width="67%">
<script language="Javascript">
<!--
myMsg = "Welcome to marquee!!! "
i=0
function scrollMsg() {
frontPart = myMsg.substring(i,myMsg.length)
backPart = myMsg.substring(0,i)
window.status = frontPart + backPart
if (i < myMsg.length) {
i++
}
else {
i = 0
}
setTimeout("scrollMsg()",50)
}
window.onload=scrollMsg
//-->
</script>
</center>
<!-- php script END -->
<table>
<td width="200" valign="top">
<div align="left">
<table width="100%" border="1" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td>
<div align="center"><strong>NEWS FLASH </strong></div>
<center>
<marquee height="65" scrollamount="1" direction="up" onmouseover="this.stop()" onmouseout="this.start()"><center>Welcome to my little scroll bar..that does not take data from mysql database...yet</center></marquee>
</center>
<div align="center">
<table border="0" cellpadding="0" cellspacing="0" width="100%" background="#FFfFFF" height="20">
<tr>
<td>
<p align="center"><font color="#FFFFFF">
<b></b></font></td>
</tr>
</table>
</div>
</td>
</tr>
</table>
</div>
</td>
<tr>
<td colspan="2" valign="top"> </td>
</tr>
</body>
Replies
Replied 21 Nov 2006 13:37:42
21 Nov 2006 13:37:42 Vince Baker replied:
you need to pass the dynamic value into the script when you call it.
i have amended a few bits of your code to show you how:
onmouseout="this.start('<%=yourrecordset("fieldname"%>')"
and
<script language="Javascript">
<!--
i=0
function scrollMsg(varDynamicText) {
myMsg = varDynamicText
frontPart = myMsg.substring(i,myMsg.length)
backPart = myMsg.substring(0,i)
window.status = frontPart + backPart
if (i < myMsg.length) {
i++
}
else {
i = 0
}
setTimeout("scrollMsg()",50)
}
window.onload=scrollMsg
that should do the trick
Regards
Vince Baker
<strong>DMX Zone Manager</strong>
[VBScript | ASP | HTML | CSS | SQL | Oracle | AS400 | ERP Logic | Hosting]
i have amended a few bits of your code to show you how:
onmouseout="this.start('<%=yourrecordset("fieldname"%>')"
and
<script language="Javascript">
<!--
i=0
function scrollMsg(varDynamicText) {
myMsg = varDynamicText
frontPart = myMsg.substring(i,myMsg.length)
backPart = myMsg.substring(0,i)
window.status = frontPart + backPart
if (i < myMsg.length) {
i++
}
else {
i = 0
}
setTimeout("scrollMsg()",50)
}
window.onload=scrollMsg
that should do the trick
Regards
Vince Baker
<strong>DMX Zone Manager</strong>
[VBScript | ASP | HTML | CSS | SQL | Oracle | AS400 | ERP Logic | Hosting]
Replied 21 Nov 2006 14:20:41
21 Nov 2006 14:20:41 sally bierton replied:
Hi thanks for that...although i am still a little unsure..i have added the table but can still not get the data to arrive in the marquee.
here is what i changed the script to...
<script language="JavaScript" ></script>
<html xmlns="www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>addpaymentform</title>
<style type="text/css">
<!--
a:link {
color: ff0000;
}
a:visited {
color: ff0000;
}
a:active {
color: ff0000;
}
body,td,th {
font-family: veranda;
font-size: small;
color: 000080;
}
body {
background-color: #D6DFF7;
}
a:hover {
color: ff0000;
}
-->
</style></head>
<body
<td width="1" bgcolor="#fffFF"></td>
<td width="67%">
<?
include("connection.php"
$query = 'CREATE TABLE news( '.
'newsLine VARCHAR(20) NOT NULL, '.
'PRIMARY KEY(newsline))';
$query =" INSERT INTO news () VALUES ('this is the information i want in the marquee')";
$query = "SELECT * FROM news";
$result = mysql_query($query) or die('Error, query failed');
mysql_query($query);
$tsv = array();
$html = array();
while($row = mysql_fetch_array($result, MYSQL_NUM))
{
$tsv[] = implode("\t", $row);
$html[] = "<tr><td>" .implode("</td><td>", $row) . "</td></tr>";
}
$tsv = implode("\r\n", $tsv);
$html = "<table>" . implode("\r\n", $html) . "</table>";
$fileName = 'mysql-to-excel.xls';
echo $tsv;
//echo $html;
?>
<script language="Javascript">
myMsg = "Welcome to marquee!!! "
i=0
function scrollMsg() {
frontPart = myMsg.substring(i,myMsg.length)
backPart = myMsg.substring(0,i)
window.status = frontPart + backPart
if (i < myMsg.length) {
i++
}
else {
i = 0
}
setTimeout("scrollMsg()",50)
}
window.onload=scrollMsg
//-->
</script>
</center>
<!-- php script END -->
<table>
<td width="200" valign="top">
<div align="left">
<table width="100%" border="1" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td>
<div align="center"><strong><u>NEWS FLASH</u> </strong></div>
<center>
<marquee height="65" scrollamount="1" direction="up" onMouseOver="this.stop()" onMouseOut="this.start()"><center>
</center></marquee>
</center>
<div align="center">
<table border="0" cellpadding="0" cellspacing="0" width="100%" background="#FFFFFF" height="20">
<tr>
<td>
<p align="center"><font color="#FFFFFF">
<b></b></font></td>
</tr>
</table>
</div>
</td>
</tr>
</table>
</div>
</td>
<tr>
<td colspan="2" valign="top"> </td>
</tr>
</body>
here is what i changed the script to...
<script language="JavaScript" ></script>
<html xmlns="www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>addpaymentform</title>
<style type="text/css">
<!--
a:link {
color: ff0000;
}
a:visited {
color: ff0000;
}
a:active {
color: ff0000;
}
body,td,th {
font-family: veranda;
font-size: small;
color: 000080;
}
body {
background-color: #D6DFF7;
}
a:hover {
color: ff0000;
}
-->
</style></head>
<body
<td width="1" bgcolor="#fffFF"></td>
<td width="67%">
<?
include("connection.php"
$query = 'CREATE TABLE news( '.
'newsLine VARCHAR(20) NOT NULL, '.
'PRIMARY KEY(newsline))';
$query =" INSERT INTO news () VALUES ('this is the information i want in the marquee')";
$query = "SELECT * FROM news";
$result = mysql_query($query) or die('Error, query failed');
mysql_query($query);
$tsv = array();
$html = array();
while($row = mysql_fetch_array($result, MYSQL_NUM))
{
$tsv[] = implode("\t", $row);
$html[] = "<tr><td>" .implode("</td><td>", $row) . "</td></tr>";
}
$tsv = implode("\r\n", $tsv);
$html = "<table>" . implode("\r\n", $html) . "</table>";
$fileName = 'mysql-to-excel.xls';
echo $tsv;
//echo $html;
?>
<script language="Javascript">
myMsg = "Welcome to marquee!!! "
i=0
function scrollMsg() {
frontPart = myMsg.substring(i,myMsg.length)
backPart = myMsg.substring(0,i)
window.status = frontPart + backPart
if (i < myMsg.length) {
i++
}
else {
i = 0
}
setTimeout("scrollMsg()",50)
}
window.onload=scrollMsg
//-->
</script>
</center>
<!-- php script END -->
<table>
<td width="200" valign="top">
<div align="left">
<table width="100%" border="1" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td>
<div align="center"><strong><u>NEWS FLASH</u> </strong></div>
<center>
<marquee height="65" scrollamount="1" direction="up" onMouseOver="this.stop()" onMouseOut="this.start()"><center>
</center></marquee>
</center>
<div align="center">
<table border="0" cellpadding="0" cellspacing="0" width="100%" background="#FFFFFF" height="20">
<tr>
<td>
<p align="center"><font color="#FFFFFF">
<b></b></font></td>
</tr>
</table>
</div>
</td>
</tr>
</table>
</div>
</td>
<tr>
<td colspan="2" valign="top"> </td>
</tr>
</body>