Results 1 to 9 of 9

Thread: Pausing up-down Scroller - adding data

  1. #1
    Join Date
    Jun 2008
    Posts
    6
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Pausing up-down Scroller - adding data

    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

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    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:

    Code:
    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:

    PHP Code:
    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.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. The Following User Says Thank You to jscheuer1 For This Useful Post:

    andymut (06-17-2008)

  4. #3
    Join Date
    Jun 2008
    Posts
    6
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by jscheuer1 View Post

    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:

    PHP Code:
    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

  5. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    You can't do that because it would be somewhat like doing:

    Code:
    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>'
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  6. The Following User Says Thank You to jscheuer1 For This Useful Post:

    andymut (06-18-2008)

  7. #5
    Join Date
    Jun 2008
    Posts
    6
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    so what can be done pls?

  8. #6
    Join Date
    Jun 2008
    Posts
    6
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    what's the alternative?

  9. #7
    Join Date
    Jun 2008
    Posts
    6
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    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

  10. #8
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by andymut View Post
    what's the alternative?
    You need to construct a valid javascript array. One that will end up looking something like:

    Code:
    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:

    Code:
    pausecontent[#]
    entry separately, you cannot hard code:

    Code:
    pausecontent[0]=
    So something like:

    PHP Code:
    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...es.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.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  11. #9
    Join Date
    Jun 2008
    Posts
    6
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Ok.
    Let me try that and see....

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •