Forums

PHP

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

&lt;script language="JavaScript" &gt;&lt;/script&gt;
&lt;html xmlns="www.w3.org/1999/xhtml"&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /&gt;
&lt;title&gt;addpaymentform&lt;/title&gt;
&lt;style type="text/css"&gt;
&lt;!--
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;
}
--&gt;
&lt;/style&gt;&lt;/head&gt;
&lt;body
&lt;td width="1" bgcolor="#fffFF"&gt;&lt;/td&gt;
&lt;td width="67%"&gt;
&lt;?
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[] = "&lt;tr&gt;&lt;td&gt;" .implode("&lt;/td&gt;&lt;td&gt;", $row) . "&lt;/td&gt;&lt;/tr&gt;";
}

$tsv = implode("\r\n", $tsv);
$html = "&lt;table&gt;" . implode("\r\n", $html) . "&lt;/table&gt;";

$fileName = 'mysql-to-excel.xls';


echo $tsv;
//echo $html;
?&gt;
&lt;script language="Javascript"&gt;

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 &lt; myMsg.length) {
i++
}
else {
i = 0
}

setTimeout("scrollMsg()",50)

}

window.onload=scrollMsg
//--&gt;
&lt;/script&gt;
&lt;/center&gt;
&lt;!-- php script END --&gt;
&lt;table&gt;
&lt;td width="200" valign="top"&gt;
&lt;div align="left"&gt;

&lt;table width="100%" border="1" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;div align="center"&gt;&lt;strong&gt;&lt;u&gt;NEWS FLASH&lt;/u&gt; &lt;/strong&gt;&lt;/div&gt;

&lt;center&gt;

&lt;marquee height="65" scrollamount="1" direction="up" onMouseOver="this.stop()" onMouseOut="this.start()"&gt;&lt;center&gt;
&lt;/center&gt;&lt;/marquee&gt;
&lt;/center&gt;
&lt;div align="center"&gt;
&lt;table border="0" cellpadding="0" cellspacing="0" width="100%" background="#FFFFFF" height="20"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;p align="center"&gt;&lt;font color="#FFFFFF"&gt;
&lt;b&gt;&lt;/b&gt;&lt;/font&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;tr&gt;
&lt;td colspan="2" valign="top"&gt;&nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;/body&gt;


Reply to this topic