Support Forum Softcomplex logo
About Us  | Services  | Download  | Order  | Support  | |
| Search | Today's Posts | Stats | Board Rules | Not logged in [ Login | Register ]
go to bottom
Last active: Never

Printable Version | Subscribe | Add to Favourites   Post new thread
Author: Subject: Solution for Dynamic Dbase Data

Posts: 1
Registered: 10/7/2005
Location: Washington, DC
Member Is Offline
posted on 10/7/2005 at 03:30 AM Reply With Quote
Solution for Dynamic Dbase Data

Just downloaded Tigra Scroller and it looks like just the thing I needed. Saw a bunch of posts on here regarding how to post dynamic data. Here's a simple way for anyone who is looking to do it.

1. As per an earlier post by Rock, make a quick edit to the scroll.html file:

scroll.html changes are line 19:
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'>")

2. Rename whichever scroll.tpl.js file you are using to .php, as in:
scroll.tpl1.js becomes scroll.tpl1.php.

3. At the top of that file enter your database connect info. and query and push the results into an array, like so:

[email protected]_connect("address","user","pass");
[email protected]_select_db("db_name",$db);
$query="SELECT * FROM new_posts WHERE active = 'true' ORDER BY post_date ASC LIMIT 10");
while ($row=mysql_fetch_assoc($result)){

4. In the above example you're pulling the ten most recent posts from a MySQL dbase sorted by post date. They are then getting pushed into the array called $array so that $array[0] will equal the first post title, $array[1] will equal the second post title and so on.

5. Change your content portion under ITEMS to read:
'content' : '<?php echo $array[0]; ?>', for the first one
'content' : '<?php echo $array[1]; ?>', for the second one and so on for as many records as you wish to display

If you're looking to pull multiple fields, like the post's title, author and contents, you can use a multidimensional array. For example, above I have it getting the contents of one field, post_title. Suppose you want to also show the date the post was made. Simply add another line for it right below the one for post_title, like so:
$post_date= $row['post_date'];

Then add one line right before your array_push like this:
$posts=array("date"=>$post_date, "title"=>$post_title);

and change your array_push to

Now each $array[0] etc. will hold an array itself that you can access in your content section.

Then your entries for content would look like this:
'content' : '<?php echo $array[0][date]."<br>".$array[0][title]; ?>',

Just add as many fields as you want to the $posts array giving each one a title and indicating what $value to put into it (ie: after "title"=>$post_title you could add "poster"=>$poster, "email"=>$email, etc.)

One thing I did notice is that you need to make sure you're returning as many results as you have content elements. Meaning that if you have it set up to show five results but you've only got two records in your database it doesn't work -- something in the scroll code and I haven't looked at it yet to see why. If you're worried about that happening you simply move the ITEMS info into the while loop above and have it actually generate as many items as it finds results. If that makes no sense and you have this problem let me know and I'll post the code.

Hope this helps. Great script.
View User's Profile View All Posts By User U2U Member

Posts: 1
Registered: 3/13/2006
Location: belgium
Member Is Offline
posted on 3/13/2006 at 06:58 PM Reply With Quote
To complete... as example

Thank you a lot for your app's... it is very useful to gain some place on a web page... And when I saw that I wonder if it was possible to display dynamic datas ? You, "ontapdc", answer to my question... so I give you a snippet of code to (maybe) complete your!

Thank you again

$sql = "SELECT * FROM EVENTS WHERE post_active = 'true' ORDER BY post_date ASC";
$link = mysql_connect("server", "user", "pass") OR die ();
mysql_select_db("lautrebe") OR die();
$result = mysql_query($sql) OR die();
$num_rows = mysql_num_rows($result);
var LOOK = {'size': [210, 108]},
BEHAVE = {'auto': true,'vertical': true,'speed': 1},

while($row = mysql_fetch_object ( $result ) ){
if($i == $num_rows){
echo "{'file': '','content': '<div class=\"events\"><h4>$row->post_title</h4><h5>[$row->post_date]</h5><p><a href=\"events/?id=$row->post_id\">$row->post_event</a></p></div>','pause_b': 2,'pause_a': 0}";
echo "{'file': '','content': '<div class=\"events\"><h4>$row->post_title</h4><h5>[$row->post_date]</h5><p><a href=\"events/?id=$row->post_id\">$row->post_event</a></p></div>','pause_b': 2,'pause_a': 0},";

... et voilA?!

The adding part is there to generate all the datas from the db.

Tested and approved!
Uhm! ... I suggest maybe to escape the " ' " before inserting into the db because when the app's meet a " ' "... it don't like it and as simple as I write it, IT CRASHES!
View User's Profile View All Posts By User U2U Member

Posts: 1
Registered: 1/8/2007
Location: philippines
Member Is Offline
posted on 1/8/2007 at 07:07 AM Reply With Quote
Simple way to get data from database

This is what i did, simple. Tested it. Works in mozilla, ie6 and ie7. can't test in safari, i don't have safari.

LOOK = {
// scroller box size: [width, height]
'size' : [180, 225],
// for on-demand mode: path to image for scrolling items backward
// if relative than to Tscroll_path_to_files
'up' : 'alf.gif',
// for on-demand mode: path to image for scrolling items forward
// if relative than to Tscroll_path_to_files
'dn' : 'art.gif'

// if scrolling mode is auto (true / false);
'auto' : false,
// if scrolling direction is vertical (true / false, false means horisontal)
'vertical' : true,
// scrolling speed, pixels per 40 miliseconds;
// for auto mode use negative value to reverse scrolling direction
'speed' : 6
// a data to build scroll window content

'file': 'phpfilewithmysql.php, //create a separate php file, have your mysql/php statement in that separate file, you can format your display, then simply call it in the file. based on the documentation of tigra scroller, if you place something on the file field the content field will be ignored.
'content': '',
'pause_b': 1,
'pause_a': 0
View User's Profile View All Posts By User U2U Member

Posts: 1
Registered: 3/2/2007
Location: Oslo, Norway
Member Is Offline
posted on 3/2/2007 at 10:22 AM Reply With Quote

Thanks to earlier posts, they provided ALMOST what I needed...
My case requires use of $_GET to provide the ID in the datacollection, and I can't find a way to make that work..... It returns empty, with no error messages.
Any ideas, anybody?
View User's Profile View All Posts By User U2U Member
Junior Member

Posts: 2
Registered: 4/2/2012
Location: Lagos Nigeria
Member Is Offline
posted on 4/2/2012 at 04:57 PM Reply With Quote

Please can anyone help me out. I have been able to pull data from DB to my scroller, but on my page, it does not refresh except I use the html meta content refresh command before the new information will be seem on the page. I do not like this, I expect that internally, the scroller will be doing the refresh
View User's Profile View All Posts By User U2U Member
Post new thread

Related Links:
Tigra Scroller
Product Demonstrations Live Demos:
Multiple vertical scrolling
Horizontal scrolling
Free Download Free Download
Product Documentation Documentation:
Documenation Page
Change Log
Support Forum Technical Support
Support Forum
Tigra Scroller PRO
Product Demonstrations Live Demos
Vertical automatic scrolling
Horizontal manual scrolling
Product Documentation Documentation
Documenation Page
Change Log
Support Forum Technical Support
Support Forum
Customer Care System
Order Now ORDER NOW!
Add to Cart
View Cart

Go To Top

Powered by XMB 1.9.1 Nexus
Developed By Aventure Media & The XMB Group © 2002-2004