Results 1 to 3 of 3

Thread: Code Check Please - Ticker

  1. #1
    Join Date
    Aug 2007
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Code Check Please - Ticker

    Hey ya guys, Im trying to addapt a some ticker code to pull from a database, Im having some problems, can someone check this code for me please.

    The ticker should be appearing on http://www.baroquerecords.com (directly below the navigation)

    PHP Code:

    <script type="text/javascript">

    /*Example message arrays for the two demo scrollers*/

    var pausecontent2=new Array()
    pausecontent2[0]='<a href="<?php echo $row_ts_ticker1['ticker_link']; ?>"><?php echo $row_ts_ticker1['ticker_news']; ?></a>'
    pausecontent2[1]='<a href="<?php echo $row_ts_ticker2['ticker_link']; ?>"><?php echo $row_ts_ticker2['ticker_news']; ?></a>'
    pausecontent2[2]='<a href="<?php echo $row_ts_ticker3['ticker_link']; ?>"><?php echo $row_ts_ticker3['ticker_news']; ?></a>'

    </script>

    This has been driving me mad for a week now, also does anyone know a good open source php/mysql new news ticker system?
    Last edited by DRONE; 10-05-2007 at 10:08 AM.

  2. #2
    Join Date
    Aug 2007
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Here's the 'head' code...

    PHP Code:

    <?php require_once('Connections/baroquedb.php'); ?>
    <?php
    if (!function_exists("GetSQLValueString")) {
    function 
    GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
    {
      
    $theValue get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

      
    $theValue function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

      switch (
    $theType) {
        case 
    "text":
          
    $theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
          break;    
        case 
    "long":
        case 
    "int":
          
    $theValue = ($theValue != "") ? intval($theValue) : "NULL";
          break;
        case 
    "double":
          
    $theValue = ($theValue != "") ? "'" doubleval($theValue) . "'" "NULL";
          break;
        case 
    "date":
          
    $theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
          break;
        case 
    "defined":
          
    $theValue = ($theValue != "") ? $theDefinedValue $theNotDefinedValue;
          break;
      }
      return 
    $theValue;
    }
    }

    if (!
    function_exists("GetSQLValueString")) {
    function 
    GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
    {
      
    $theValue get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

      
    $theValue function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

      switch (
    $theType) {
        case 
    "text":
          
    $theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
          break;    
        case 
    "long":
        case 
    "int":
          
    $theValue = ($theValue != "") ? intval($theValue) : "NULL";
          break;
        case 
    "double":
          
    $theValue = ($theValue != "") ? "'" doubleval($theValue) . "'" "NULL";
          break;
        case 
    "date":
          
    $theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
          break;
        case 
    "defined":
          
    $theValue = ($theValue != "") ? $theDefinedValue $theNotDefinedValue;
          break;
      }
      return 
    $theValue;
    }
    }

    if (!
    function_exists("GetSQLValueString")) {
    function 
    GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
    {
      
    $theValue get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

      
    $theValue function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

      switch (
    $theType) {
        case 
    "text":
          
    $theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
          break;    
        case 
    "long":
        case 
    "int":
          
    $theValue = ($theValue != "") ? intval($theValue) : "NULL";
          break;
        case 
    "double":
          
    $theValue = ($theValue != "") ? "'" doubleval($theValue) . "'" "NULL";
          break;
        case 
    "date":
          
    $theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
          break;
        case 
    "defined":
          
    $theValue = ($theValue != "") ? $theDefinedValue $theNotDefinedValue;
          break;
      }
      return 
    $theValue;
    }
    }

    if (!
    function_exists("GetSQLValueString")) {
    function 
    GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
    {
      
    $theValue get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

      
    $theValue function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

      switch (
    $theType) {
        case 
    "text":
          
    $theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
          break;    
        case 
    "long":
        case 
    "int":
          
    $theValue = ($theValue != "") ? intval($theValue) : "NULL";
          break;
        case 
    "double":
          
    $theValue = ($theValue != "") ? "'" doubleval($theValue) . "'" "NULL";
          break;
        case 
    "date":
          
    $theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
          break;
        case 
    "defined":
          
    $theValue = ($theValue != "") ? $theDefinedValue $theNotDefinedValue;
          break;
      }
      return 
    $theValue;
    }
    }

    mysql_select_db($database_baroquedb$baroquedb);
    $query_rs_content "SELECT * FROM tbl_textcontent WHERE content_section = 'home' ORDER BY content_order ASC";
    $rs_content mysql_query($query_rs_content$baroquedb) or die(mysql_error());
    $row_rs_content mysql_fetch_assoc($rs_content);
    $totalRows_rs_content mysql_num_rows($rs_content);

    mysql_select_db($database_baroquedb$baroquedb);
    $query_rs_labels "SELECT * FROM tbl_labels ORDER BY label_id ASC";
    $rs_labels mysql_query($query_rs_labels$baroquedb) or die(mysql_error());
    $row_rs_labels mysql_fetch_assoc($rs_labels);
    $totalRows_rs_labels mysql_num_rows($rs_labels);

    mysql_select_db($database_baroquedb$baroquedb);
    $query_rs_artists "SELECT * FROM tbl_artists ORDER BY artist_name ASC";
    $rs_artists mysql_query($query_rs_artists$baroquedb) or die(mysql_error());
    $row_rs_artists mysql_fetch_assoc($rs_artists);
    $totalRows_rs_artists mysql_num_rows($rs_artists);

    $maxRows_rs_leftrelease 3;
    $pageNum_rs_leftrelease 0;
    if (isset(
    $_GET['pageNum_rs_leftrelease'])) {
      
    $pageNum_rs_leftrelease $_GET['pageNum_rs_leftrelease'];
    }
    $startRow_rs_leftrelease $pageNum_rs_leftrelease $maxRows_rs_leftrelease;

    mysql_select_db($database_baroquedb$baroquedb);
    $query_rs_leftrelease "SELECT * FROM tbl_l_release";
    $query_limit_rs_leftrelease sprintf("%s LIMIT %d, %d"$query_rs_leftrelease$startRow_rs_leftrelease$maxRows_rs_leftrelease);
    $rs_leftrelease mysql_query($query_limit_rs_leftrelease$baroquedb) or die(mysql_error());
    $row_rs_leftrelease mysql_fetch_assoc($rs_leftrelease);

    if (isset(
    $_GET['totalRows_rs_leftrelease'])) {
      
    $totalRows_rs_leftrelease $_GET['totalRows_rs_leftrelease'];
    } else {
      
    $all_rs_leftrelease mysql_query($query_rs_leftrelease);
      
    $totalRows_rs_leftrelease mysql_num_rows($all_rs_leftrelease);
    }
    $totalPages_rs_leftrelease ceil($totalRows_rs_leftrelease/$maxRows_rs_leftrelease)-1;

    $maxRows_rs_rightrelease 3;
    $pageNum_rs_rightrelease 0;
    if (isset(
    $_GET['pageNum_rs_rightrelease'])) {
      
    $pageNum_rs_rightrelease $_GET['pageNum_rs_rightrelease'];
    }
    $startRow_rs_rightrelease $pageNum_rs_rightrelease $maxRows_rs_rightrelease;

    mysql_select_db($database_baroquedb$baroquedb);
    $query_rs_rightrelease "SELECT * FROM tbl_r_release";
    $query_limit_rs_rightrelease sprintf("%s LIMIT %d, %d"$query_rs_rightrelease$startRow_rs_rightrelease$maxRows_rs_rightrelease);
    $rs_rightrelease mysql_query($query_limit_rs_rightrelease$baroquedb) or die(mysql_error());
    $row_rs_rightrelease mysql_fetch_assoc($rs_rightrelease);

    if (isset(
    $_GET['totalRows_rs_rightrelease'])) {
      
    $totalRows_rs_rightrelease $_GET['totalRows_rs_rightrelease'];
    } else {
      
    $all_rs_rightrelease mysql_query($query_rs_rightrelease);
      
    $totalRows_rs_rightrelease mysql_num_rows($all_rs_rightrelease);
    }
    $totalPages_rs_rightrelease ceil($totalRows_rs_rightrelease/$maxRows_rs_rightrelease)-1;

    mysql_select_db($database_baroquedb$baroquedb);
    $query_ts_ticker1 "SELECT * FROM tbl_ticker WHERE ticker_id = 1";
    $ts_ticker1 mysql_query($query_ts_ticker1$baroquedb) or die(mysql_error());
    $row_ts_ticker1 mysql_fetch_assoc($ts_ticker1);
    $totalRows_ts_ticker1 mysql_num_rows($ts_ticker1);

    mysql_select_db($database_baroquedb$baroquedb);
    $query_rs_ticker2 "SELECT * FROM tbl_ticker WHERE ticker_id = 2";
    $rs_ticker2 mysql_query($query_rs_ticker2$baroquedb) or die(mysql_error());
    $row_rs_ticker2 mysql_fetch_assoc($rs_ticker2);
    $totalRows_rs_ticker2 mysql_num_rows($rs_ticker2);

    mysql_select_db($database_baroquedb$baroquedb);
    $query_rs_ticker3 "SELECT * FROM tbl_ticker WHERE ticker_id = 3";
    $rs_ticker3 mysql_query($query_rs_ticker3$baroquedb) or die(mysql_error());
    $row_rs_ticker3 mysql_fetch_assoc($rs_ticker3);
    $totalRows_rs_ticker3 mysql_num_rows($rs_ticker3);
    ?>

  3. #3
    Join Date
    Aug 2007
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Here's the rest of the ticker code...

    PHP Code:

    <script type="text/javascript">

    /***********************************************
    * Pausing up-down scroller-  Dynamic Drive (www.dynamicdrive.com)
    * This notice MUST stay intact for legal use
    * Visit http://www.dynamicdrive.com/ for this script and 100s more.
    ***********************************************/

    function pausescroller(contentdivIddivClassdelay){
    this.content=content //message array content
    this.tickerid=divId //ID of ticker div to display information
    this.delay=delay //Delay between msg change, in miliseconds.
    this.mouseoverBol=//Boolean to indicate whether mouse is currently over scroller (and pause it if it is)
    this.hiddendivpointer=//index of message array for hidden div
    document.write('<div id="'+divId+'" class="'+divClass+'" style="position: relative; overflow: hidden"><div class="innerDiv" style="position: absolute; width: 100%" id="'+divId+'1">'+content[0]+'</div><div class="innerDiv" style="position: absolute; width: 100%; visibility: hidden" id="'+divId+'2">'+content[1]+'</div></div>')
    var 
    scrollerinstance=this
    if (window.addEventListener//run onload in DOM2 browsers
    window.addEventListener("load", function(){scrollerinstance.initialize()}, false)
    else if (
    window.attachEvent//run onload in IE5.5+
    window.attachEvent("onload", function(){scrollerinstance.initialize()})
    else if (
    document.getElementById//if legacy DOM browsers, just start scroller after 0.5 sec
    setTimeout(function(){scrollerinstance.initialize()}, 500)
    }

    // -------------------------------------------------------------------
    // initialize()- Initialize scroller method.
    // -Get div objects, set initial positions, start up down animation
    // -------------------------------------------------------------------

    pausescroller.prototype.initialize=function(){
    this.tickerdiv=document.getElementById(this.tickerid)
    this.visiblediv=document.getElementById(this.tickerid+"1")
    this.hiddendiv=document.getElementById(this.tickerid+"2")
    this.visibledivtop=parseInt(pausescroller.getCSSpadding(this.tickerdiv))
    //set width of inner DIVs to outer DIV's width minus padding (padding assumed to be top padding x 2)
    this.visiblediv.style.width=this.hiddendiv.style.width=this.tickerdiv.offsetWidth-(this.visibledivtop*2)+"px"
    this.getinline(this.visibledivthis.hiddendiv)
    this.hiddendiv.style.visibility="visible"
    var scrollerinstance=this
    document
    .getElementById(this.tickerid).onmouseover=function(){scrollerinstance.mouseoverBol=1}
    document.getElementById(this.tickerid).onmouseout=function(){scrollerinstance.mouseoverBol=0}
    if (
    window.attachEvent//Clean up loose references in IE
    window.attachEvent("onunload", function(){scrollerinstance.tickerdiv.onmouseover=scrollerinstance.tickerdiv.onmouseout=null})
    setTimeout(function(){scrollerinstance.animateup()}, this.delay)
    }


    // -------------------------------------------------------------------
    // animateup()- Move the two inner divs of the scroller up and in sync
    // -------------------------------------------------------------------

    pausescroller.prototype.animateup=function(){
    var 
    scrollerinstance=this
    if (parseInt(this.hiddendiv.style.top)>(this.visibledivtop+5)){
    this.visiblediv.style.top=parseInt(this.visiblediv.style.top)-5+"px"
    this.hiddendiv.style.top=parseInt(this.hiddendiv.style.top)-5+"px"
    setTimeout(function(){scrollerinstance.animateup()}, 50)
    }
    else{
    this.getinline(this.hiddendivthis.visiblediv)
    this.swapdivs()
    setTimeout(function(){scrollerinstance.setmessage()}, this.delay)
    }
    }

    // -------------------------------------------------------------------
    // swapdivs()- Swap between which is the visible and which is the hidden div
    // -------------------------------------------------------------------

    pausescroller.prototype.swapdivs=function(){
    var 
    tempcontainer=this.visiblediv
    this
    .visiblediv=this.hiddendiv
    this
    .hiddendiv=tempcontainer
    }

    pausescroller.prototype.getinline=function(div1div2){
    div1.style.top=this.visibledivtop+"px"
    div2.style.top=Math.max(div1.parentNode.offsetHeightdiv1.offsetHeight)+"px"
    }

    // -------------------------------------------------------------------
    // setmessage()- Populate the hidden div with the next message before it's visible
    // -------------------------------------------------------------------

    pausescroller.prototype.setmessage=function(){
    var 
    scrollerinstance=this
    if (this.mouseoverBol==1//if mouse is currently over scoller, do nothing (pause it)
    setTimeout(function(){scrollerinstance.setmessage()}, 100)
    else{
    var 
    i=this.hiddendivpointer
    var ceiling=this.content.length
    this
    .hiddendivpointer=(i+1>ceiling-1)? i+1
    this
    .hiddendiv.innerHTML=this.content[this.hiddendivpointer]
    this.animateup()
    }
    }

    pausescroller.getCSSpadding=function(tickerobj){ //get CSS padding value, if any
    if (tickerobj.currentStyle)
    return 
    tickerobj.currentStyle["paddingTop"]
    else if (
    window.getComputedStyle//if DOM2
    return window.getComputedStyle(tickerobj"").getPropertyValue("padding-top")
    else
    return 
    0
    }

    </script> 

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
  •