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: PHP Idiot needs code help for scroll.tpo0.php
steamngn
Junior Member

Posts: 2
Registered: 10/22/2006
Location: Middletown, NY
Member Is Offline
posted on 10/22/2006 at 01:34 PM Reply With Quote
PHP Idiot needs code help for scroll.tpo0.php


Hi All! EXCELLENT piece of coding, this scroller...
now if only my php ability were this good!
I am TRYING to get scroll.tpo0.js changed over to php to connect to MySQL. I am pathetic at this, and am having trouble. Here is my code so far:

<?php
[email protected]_connect("mysql.bluedomino.com","chungmanews","kicking");
[email protected]_select_db("scroller",$db);
$query="SELECT * FROM scroller ORDER BY id ASC LIMIT 3";
$result=mysql_query($query);
$array=array();
while ($row=mysql_fetch_assoc($result)){
$id=$row['id'];
$name= $row['name'];
$posts=array("name"=>$name, "id"=>$id);
array_push($array,$posts);
}
?>
var LOOK = {
// scroller box size: [width, height]
'size': [350, 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': 5
},

// 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': '<?php echo $array[0][id]."<br>".$array[0][name]; ?>',
'pause_b': 2,
'pause_a': 0
},
{
'file': '',
'content' : '<?php echo $array[1][id]."<br>".$array[1][name]; ?>',
'pause_b': 2,
'pause_a': 0
},
{
'file': '',
// note: image path is relative to the ts_files directory
'content' : '<?php echo $array[2][id]."<br>".$array[2][name]; ?>',
'pause_b': 2,
'pause_a': 0
}
// add as many items here as you need.
// don't forget to separate them with commas, make sure there is no comma after the last item
]

Ok, I found the post regarding dynamic data, and re wrote my PHP to the above code. This is working. I notice at this post:
http://www.softcomplex.com/forum/viewthread_2490/
that jeviridon has ASP code that will pull however many rows are returned WITHOUT hard coding it. can this be done is php, and f so, how?
Now I know that this is not quite right. Can anyone help sort this php nimrod out? :)
Andy
View User's Profile View All Posts By User U2U Member
tigra
Administrator

Posts: 2049
Registered: 6/17/2002
Location: US, CO
Member Is Offline
posted on 10/23/2006 at 09:07 AM Reply With Quote

now instead of static items inside the ITEMS = [...] add the loop in which you echo the data for each scroller's item. You can then request the page via http and view the resulting code by using view->source feature of your browser.
View User's Profile View All Posts By User U2U Member
steamngn
Junior Member

Posts: 2
Registered: 10/22/2006
Location: Middletown, NY
Member Is Offline
posted on 10/23/2006 at 01:36 PM Reply With Quote

Well...
I've been trying my best, but not having any luck. I can't seem to get the loop syntax right to return the correct string(s) of data.
I've been tinkering around with it all day with no luck. What should the string look like?
Here is my most recent attempt:

$x = 0;
while ($x<=$numrows){
if ($x<$numrows){
$test = $test."\'file\':\'\',\'content\':\'".$x. $array[$x][id]."<br>".$array[$x][name]."\',\'pause_b\': 2,\'pause_a\': 0".",";
}else if ($x==$numrows){
$test = $test."\'file\':\'\',\'content\':\'".$x. $array[$x][id]."<br>".$array[$x][name]."\',\'pause_b\': 2,\'pause_a\': 0";
}
++$x;

This builds a string of all the records from the array, but is obviously wrong or missing something....My php is not good, still learning...
Any ideas?
Andy
View User's Profile View All Posts By User U2U Member
tigra
Administrator

Posts: 2049
Registered: 6/17/2002
Location: US, CO
Member Is Offline
posted on 10/23/2006 at 07:01 PM Reply With Quote

I don't see where you echo the string. Also don't use <br> in the string. It's JavaScript, not HTML. If you need endline then echo "\n". I'm not a php person so there may be some more problems with the php code and the results it generate.
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