Board Logo

get data from Mysql ??
highlander - 4/8/2003 at 06:49 PM

Hi, would it be possible to tell scroll.tpl?.js to get its items from an MySql database using php ?

I don't think I am allowed to rename scroll.tpl?.js to *.php and still expect it to work...

any ideas anyone ?

Thanx Highlander..

p.s. great product though..well done


nik - 4/9/2003 at 07:54 AM

Yes, it's possible but you should change code in scroll.html file: insert .php in line 19, position 81.


montydublin - 1/28/2004 at 06:16 PM

Higherlander, could you explain a little more about this ..

If you change line 19 position 81 to a .php extention do you need to create a new php file to pull in the data from mysql or should you just edit scroll.html - make it a .php file and enter your code in there.

Many thanks


alindsay55661 - 9/23/2004 at 12:42 AM

This feature is obviously a huge help to anyone looking to use this product. Has anyone accomplished this yet? Please post the results here so we can all benefit from it.


rock - 9/23/2004 at 07:57 AM

scroll.html changes are:
document.write("<script language='javascript' src='scroll.tpl" + n_id + ".php'></script><link rel='stylesheet' href='scroll" + n_id + ".css'>")

instead of

document.write("<script language='javascript' src='scroll.tpl" + n_id + ".js'></script><link rel='stylesheet' href='scroll" + n_id + ".css'>")

You could find modified scroll.html (v1.5) and tpl.php sample in the attachment.


jevridon - 4/28/2005 at 08:24 PM

This is example is okay, but the example hardly seems to be pulling in content from any kind of server. Is there an example of any rewritten file that actually pulls in data from a database?


rock - 4/29/2005 at 10:44 AM

Within scroll.tplN.php you could easily write a function to fetch any data from DB or is it an issue?


jevridon - 4/29/2005 at 03:42 PM

Yes, it is an issue because I need to build a repeat loop into the "scroll.tplN.asp" file. When I've tried a loop before, the code broke. (I did see your other response to my other post - thank you, much! I'm simply responding here so as to cover both bases.)

Example

var LOOK = {
// scroller box size: [width, height]
'size': [150, 100]
},

BEHAVE = {
// autoscroll - true, on-demand - false
'auto': true,
// vertical - true, horizontal - false
'vertical': true,
// scrolling speed, pixels per 40 milliseconds;
// for auto mode use negative value to reverse scrolling direction
'speed': 2
},

// a data to build scroll window content
ITEMS = [
{ // file to get content for item from; if is set 'content' property doesn't matter
// only body of HTML document is taken to become scroller item content
// note: external files require time for loading
// it is RECOMMENDED to use content property to speed loading up
// please, DON'T forget to set ALL IMAGE SIZES
// in either external file or in 'content' string for scroller script
// to be able to estimate item sizes

<%
Do While Not rstSimple.EOF
%>

'file': '',
'content': '<h2>Testing</h2>',
'pause_b': 2,
'pause_a': 1
},
{
'file': '',
'content': 'Second test',
'pause_b': 2,
'pause_a': 1
}
]


Even adding the "<% Do While Not rstSimple.EOF %>" breaks the file.

Is there a solution?

Thank you much.


rock - 4/29/2005 at 04:31 PM

I don't understand an indtruction "Do While Not rstSimple.EOF" could you post sensible code to analyze


jevridon - 4/29/2005 at 06:34 PM

rock,

I apologize about my lack of explanation. After fiddling around with the code, I came up with something that's not entirely dynamic, but will do the trick for as much content as necessary from a database (since it's a scroller, I don't forsee having more than 10 changing items).

<%
Dim cnnSimple ' ADO connection
Dim rstSimple ' ADO recordset
Dim objCounter ' Counter for variable content
Dim title(50)
Dim body(50)

Set cnnSimple = Server.CreateObject("ADODB.Connection")

cnnSimple.Open "Provider=SQLOLEDB;Data Source=xxx.xxx.xxx.xxx;" _
& "Initial Catalog=xxx;User Id=xxx;Password=xxx;" _
& "Connect Timeout=15;Network Library=xxx;", adOpenStatic
%>
<%
Set rstSimple = cnnSimple.Execute("SELECT * FROM announcements ORDER by id")
%>

<%
rstSimple.MoveFirst ' Move to the first record
objCounter = 0

Do While Not rstSimple.EOF

title(objCounter) = rstSimple.Fields("announcement_title")
body(objCounter) = rstSimple.Fields("announcement")

objCounter = objCounter + 1
rstSimple.MoveNext

Loop
%>

<%
rstSimple.Close
Set rstSimple = Nothing
cnnSimple.Close
Set cnnSimple = Nothing
%>

var LOOK = {
// scroller box size: [width, height]
'size': [175, 125]
},

BEHAVE = {
// autoscroll - true, on-demand - false
'auto': true,
// vertical - true, horizontal - false
'vertical': true,
// scrolling speed, pixels per 40 milliseconds;
// for auto mode use negative value to reverse scrolling direction
'speed': 2
},

// a data to build scroll window content
ITEMS = [
{ // file to get content for item from; if is set 'content' property doesn't matter
// only body of HTML document is taken to become scroller item content
// note: external files require time for loading
// it is RECOMMENDED to use content property to speed loading up
// please, DON'T forget to set ALL IMAGE SIZES
// in either external file or in 'content' string for scroller script
// to be able to estimate item sizes
'file': '',
'content': '<b><%Response.Write(title(0))%></b><br /><%Response.Write(body(0))%>',
'pause_b': 2,
'pause_a': 1
},
{

'file': '',
'content': '<b><%Response.Write(title(1))%></b><br /><%Response.Write(body(1))%>',
'pause_b': 2,
'pause_a': 1
},
{
'file': '',
'content': '<b><%Response.Write(title(2))%></b><br /><%Response.Write(body(2))%>',
'pause_b': 2,
'pause_a': 1
},
{
'file': '',
'content': '<b><%Response.Write(title(3))%></b><br /><%Response.Write(body(3))%>',
'pause_b': 2,
'pause_a': 1
}
]


I can keep adding as many scroller items as I need and all will be derived from a database! Yee-haw!

My original intent was to have this very page dynamically generate the 'file': '', 'content':'', etc. items, but I realize that I'm, most likely, barking up the wrong tree. Instead, I decided to settle for a set amount of "content" placement holders (like I said, since it's a scroller, I don't forsee having more than 10 items to scroll) and use those to hold the dynamic database content.


plucker - 4/11/2006 at 10:27 PM

I did this in ASP by writing an ASP script to generate html output driven from a sqlserver 2000 database then referencing the asp file in scroll.tpl0.js. Should be pretty similar in php/mySQL, I think.


Softcomplex: http://www.softcomplex.com/
Back to forum: http://www.softcomplex.com/forum/