PDA

View Full Version : Pausing up-down Scroller - adding data



andymut
06-16-2008, 01:07 PM
1) Script Title: Pausing up-down Scroller - adding data

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex2/crosstick.htm

3) Describe problem: Hello all, I would like some help on how I can add dynamic content from the database to use this scroller. I have a .php file that reads and displays data from the database but when I include it here it does not work - actually the whole Pausing up-down Scroller disappears.
If you can please help
Thanks

jscheuer1
06-16-2008, 04:06 PM
There are various ways to integrate PHP and javascript, and to a degree it depends upon the script, though there is more flexibility than you might think. However, to explain how it's far easier to only explain one method. That's what I'll do here. You can give the page that this script is on the .php extension. That way the server will parse it for PHP code before serving it. If you then include your PHP tokens here in this section of the on page script:


var pausecontent=new Array()
pausecontent[0]='<a href="http://www.javascriptkit.com">JavaScript Kit</a><br />Comprehensive JavaScript tutorials and over 400+ free scripts!'
pausecontent[1]='<a href="http://www.codingforums.com">Coding Forums</a><br />Web coding and development forums.'
pausecontent[2]='<a href="http://www.cssdrive.com" target="_new">CSS Drive</a><br />Categorized CSS gallery and examples.'

var pausecontent2=new Array()
pausecontent2[0]='<a href="http://www.news.com">News.com: Technology and business reports</a>'
pausecontent2[1]='<a href="http://www.cnn.com">CNN: Headline and breaking news 24/7</a>'
pausecontent2[2]='<a href="http://news.bbc.co.uk">BBC News: UK and international news</a>'

They will get used. Not knowing your exact tokens, I can only supply example syntax for an entry, just to give you the general idea:


pausecontent2[0]='<a href="<?php echo $thisLink_2a; ?>"><?php echo $thisText_2a; ?></a>'

Something like that. If you are at all familiar with PHP, you will know exactly what I'm talking about. If you're better at PHP than I am, and/or willing to go to the PHP manual on this one, you can construct the entire array by iterating through your database tokens. Though I could help with that too, especially where it would come to making sure it produces a valid javascript array.

andymut
06-17-2008, 07:50 AM
They will get used. Not knowing your exact tokens, I can only supply example syntax for an entry, just to give you the general idea:


pausecontent2[0]='<a href="<?php echo $thisLink_2a; ?>"><?php echo $thisText_2a; ?></a>'



Hello Jscheuer1
Thank you very much for taking time to look at this; Well i have (been trying even before this thread) tried the method you proposed.
The problem I am having is very straightforward - i have .php page that display all data from the database, why can't I just include it here as follows ;
----
pausecontent2[0]='<?php include (xxx.php);?>'
----
This is because the method you're proposing only renders one record.

Please see my xxx.php that displays data - below


<?php require_once('Connections/eshop.php'); ?>
<?php
mysql_select_db($database_eshop, $eshop);
$query_categories = "SELECT * FROM ads ORDER BY reply_id DESC";
$categories = mysql_query($query_categories, $eshop) or die(mysql_error());
$row_categories = mysql_fetch_assoc($categories);
$totalRows_categories = mysql_num_rows($categories);
?>
<style type="text/css">
<!--
.style2 {color: #0000FF}
.style3 {color: #3490F8}
.style4 {font-size: smaller}
-->
</style>


<span class="style10"><span class="style3">
<?php do { ?>
</MM:DECORATION></MM_REPEATEDREGION>
<MM_REPEATEDREGION SOURCE=" "><MM:DECORATION OUTLINE="Repeat" OUTLINEID=1></MM:DECORATION></MM_REPEATEDREGION>
</span>
<MM_REPEATEDREGION SOURCE=" "><MM:DECORATION OUTLINE="Repeat" OUTLINEID=1></MM:DECORATION></MM_REPEATEDREGION>
</span>
<MM_REPEATEDREGION SOURCE=" "><MM:DECORATION OUTLINE="Repeat" OUTLINEID=1><li class="style2"><span class="style10">
<?php if($totalRows_categories > 0){?>
<?php if ($row_categories['sellerimgs']!=""){?>
<a href="read2.php?mode=read&id=<?php echo $row_categories['reply_id']; ?>" title="View Larger Image"><img src="sellerimgs/<? echo $row_categories['sellerimgs'];?>" width="67" height="58" border="0" align="left" />
<?php } ?>
</a><a rel="nonfollow" href ="read2.php?mode=read&id=<?php echo $row_categories['reply_id']; ?>" title="<?php echo $row_categories['message'];?>"><?php echo substr ($row_categories['message'],0,60); ?>...</a>
<?php }else { echo "No buying leads yet. Check again after sometime.";} ?>
</span></li>
<span class="style10"><br>
<br>

<span class="style10">
<?php } while ($row_categories = mysql_fetch_assoc($categories)); ?>
</span></span>

<?php
mysql_free_result($categories);
?>

As you can see this code displays all the records in the database


So how would I use this same javascript to display all the records as in above and at the same time scroll one record at a time.


Again, thanks in advance for taking your time to look at this.

Thanks


Anderson

jscheuer1
06-17-2008, 10:30 AM
You can't do that because it would be somewhat like doing:


pausecontent2[0]='<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

</head>
<body>

</body>
</html>'

andymut
06-17-2008, 10:37 AM
so what can be done pls?

andymut
06-17-2008, 10:53 AM
what's the alternative?

andymut
06-18-2008, 09:13 AM
Hi,
I posted the below code but I still get nothing.
Please if you can assist..

var pausecontent=new Array()
pausecontent[0]='<?php do { ?><?php if($totalRows_categories > 0){?><?php if ($row_categories['sellerimgs']!=""){?><a href="read2.php?mode=read&id=<?php echo $row_categories['reply_id']; ?>" title="View Larger Image"><img src="sellerimgs/<? echo $row_categories['sellerimgs'];?>" width="67" height="58" border="0" align="left" /><?php } ?></a><a rel="nonfollow" href ="read2.php?mode=read&id=<?php echo $row_categories['reply_id']; ?>" title="<?php echo $row_categories['message'];?>"><?php echo substr ($row_categories['message'],0,60); ?>...</a><?php }else { echo "No buying leads yet. Check again after sometime.";} ?><?php } while ($row_categories = mysql_fetch_assoc($categories)); ?>'




Thanks in advance

jscheuer1
06-18-2008, 01:56 PM
what's the alternative?

You need to construct a valid javascript array. One that will end up looking something like:



var pausecontent=new Array()
pausecontent[0]='<a href="http://www.javascriptkit.com">JavaScript Kit</a><br />Comprehensive JavaScript tutorials and over 400+ free scripts!'
pausecontent[1]='<a href="http://www.codingforums.com">Coding Forums</a><br />Web coding and development forums.'
pausecontent[2]='<a href="http://www.cssdrive.com" target="_new">CSS Drive</a><br />Categorized CSS gallery and examples.'

So, for starters, unless you are going to create each:


pausecontent[#]

entry separately, you cannot hard code:


pausecontent[0]=

So something like:



var pausecontent=new Array()
<?php
$c = 0;
foreach (array_expression as $value){
echo "pausecontent[" . $c . "]='$value'\n";
$c = $c + 1;
}
?>


Must be done. (reference: http://us3.php.net/manual/en/control-structures.foreach.php - there are other PHP methods that might be more suitable for iterating your particular data source, and the above is not the exact code you would use for your data anyway.)

You can check the progress of your work by looking at the live page in the browser's 'view source'. The javascript array that is being served will appear there. It must conform to the template used/required by the scroller script.

andymut
06-18-2008, 02:02 PM
Ok.
Let me try that and see....