CodeCharge Studio
search Register Login  

Visual Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> Archive -> GotoCode Archive

 Marquee

Print topic Send  topic

Author Message
Peter K
Posted: 12/19/2003, 8:02 PM

Has anyone been able to create a marquee from rows within a database? I'm not able to figure this out. Using PHP and MySQL.
RonB
Posted: 12/20/2003, 8:22 AM

Yes, what you have to do is get the data from the databse and put it in the marquee script. I can her you say duh... at this moment :-)

First create the query that get's the info from the database.
In the script replace the pieces of code containing the info that is going to be displayed and replace them with {my_info}

Now do a set tag action that walks through the resultset (array) of the query and writes each entry to the html page. Ok I'll post both the html bits of a paige containing a scroll script and the event code for you so this is going to look terrible but might be of use

HTML:

<html>
<head>
<title>default</title>
<style type="text/css">#dropcontentsubject{ width: 100%; font-weight: bold; }
.dropcontent{ width: 100%; height: 150px; border: 1px solid black;
background-color: #DFDFFF; padding: 3px; display:block; }</style>
<script type="text/javascript">

/***********************************************
* ProHTML Ticker script- Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

var tickspeed=10000 //ticker speed in miliseconds (2000=2 seconds)
var enablesubject=1 //enable scroller subject? Set to 0 to hide

if (document.getElementById){
document.write('<style type="text/css">\n')
document.write('.dropcontent{display:none;}\n')
document.write('</style>\n')
}

var selectedDiv=0
var totalDivs=0

function contractall(){
var inc=0
while (document.getElementById("dropmsg"+inc)){
document.getElementById("dropmsg"+inc).style.display="none"
inc++
}
}


function expandone(){
var selectedDivObj=document.getElementById("dropmsg"+selectedDiv)
contractall()
document.getElementById("dropcontentsubject").innerHTML=selectedDivObj.getAttribute("subject")
selectedDivObj.style.display="block"
selectedDiv=(selectedDiv<totalDivs-1)? selectedDiv+1 : 0
setTimeout("expandone()",tickspeed)
}

function startscroller(){
while (document.getElementById("dropmsg"+totalDivs)!=null)
totalDivs++
expandone()
if (!enablesubject)
document.getElementById("dropcontentsubject").style.display="none"
}

if (window.addEventListener)
window.addEventListener("load", startscroller, false)
else if (window.attachEvent)
window.attachEvent("onload", startscroller)

</script>
</head>
<body bottommargin="0" leftmargin="0" topmargin="0" rightmargin="0" marginwidth="0" marginheight="0">
<p><font face="Tahoma">{header}</font></p>
<p>
<table cellspacing="2" cellpadding="1" width="100%" border="0">
<tr align="left" valign="top">
<td width="20%"><font size="2">
<p><font face="Tahoma" size="2"></font> </p>
</font></font> </td>
<td width="50%"><font size="2">
<p><font face="Tahoma">
<!-- BEGIN Grid news --></font>
<table>
<!-- BEGIN Row -->
<tbody>
<tr>
<td><font face="Tahoma" size="2"><strong>{news_title}</strong> </font></td>
<td width="20%">
<p align="right"><strong><font face="Tahoma" size="2">{news_date}</font></strong></p>
</td>
</tr>

<tr>
<td colspan="2"><font face="Tahoma" size="2">{news_html} </font></td>
</tr>

<tr>
<td colspan="2"><font face="Tahoma" size="2">{news_by} </font></td>
</tr>

<tr>
<td colspan="2"><font face="Tahoma" size="2">
<hr></font></td>
</tr>
<!-- END Row -->
<!-- BEGIN NoRecords -->
<tr>
<td colspan="2"><font face="Tahoma" size="2">No records </font> </td>
</tr>
<!-- END NoRecords -->
<tr>
<td colspan="2"><font face="Tahoma" size="2">
<!-- BEGIN Navigator Navigator --> 
<!-- BEGIN Pages -->
<!-- BEGIN Page_On --><a href="{Page_URL}">{Page_Number}</a> <!-- END Page_On -->
<!-- BEGIN Page_Off -->{Page_Number} <!-- END Page_Off --><!-- END Pages -->van
{Total_Pages} <!-- END Navigator Navigator --></font>  </font> </td>
</tr>

</table>
<font face="Tahoma"><!-- END Grid news --></font></p>
</font></td>
<td width="20%">
<p>
<table width="100%" border="0">
<tr>
<td>
<font face="Tahoma" size="2"><div id="dropcontentsubject">
</div>
<!-- BEGIN myblock -->{my_block}
<!-- END myblock--></font> </td>
</tr>

</table>
</font> </p>
</td>
</tr>
</tbody>
</table>
 </p>
</body>
</html>

Eventcode(php):
global $Tpl;
$db=new clsDBConnection1;
$db->query("select news_title,news_html from news where news_cat=7 and news_cluster=8 order by news_date desc");
$i=0;
while($db->next_record())
{
$my_array=Array();
$my_array["subject"]=$db->f("news_title");
$my_array["content"]=$db->f("news_html");
$num=$i;
$Tpl->SetVar("my_block", "<font face='Tahoma' size='2'><div id='dropmsg" .$num ."' class='dropcontent' subject='" .$my_array["subject"] ."'>" .$my_array["content"] ."</div></font>");
$Tpl->Parse("myblock",True);
$i++;
}
unset($db);


In the html stuff look at the myblock stuff. Hope this helps

Ron
Peter K
Posted: 12/20/2003, 11:18 AM

Wow, more code than I would have thought. I will give it try. Thanks for the detail and time it took to write this.

   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

PHP Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright 2003-2004 by UltraApps.com  and YesSoftware, Inc.