Visualizzazione dei risultati da 1 a 7 su 7

Discussione: news scrolling

  1. #1

    news scrolling

    Ciao a tutti!
    Ho bisogno di creare x un sito un piccolo spazio dove inserire le news del sito. Non voglio fare una cosa molto complicata xchè nn sarò io a gestirla, ma qualcosa che permetta all'utente di aggiornare le proprie news con un file txt o qualcosa di simile.
    Il box dovrebbe essere a scrolling verticale, passandoci sopra le notizie si fermano. Qualcosa di simile esiste, credo ma cercarla è un'impresa. Qualcuno sa consigliarmi qualche cosa??
    "fate bene l'ordinario in modo straordinario!"

  2. #2
    Guarda se su www.joesport.it le news ti piacciono: se si prendi lo script ..... Col php leggo dal db i dati

  3. #3
    si, e proprio quello che cerco! ma non capisco come prendere lo script, o meglio, ho visto il sorgente, ma come fa a leggere dal db ed a inserire le notizie? puoi farmi un esempio pratico? grazie
    "fate bene l'ordinario in modo straordinario!"

  4. #4
    HO detto una bestialità perché lo script è in php per cui non vedi il codice: eccoolo qua. Salavlo come script.js.php

    var testoesteso='';
    var testobreve='';
    /*
    testoesteso+='<div style="margin:0 2px 0 2px" >';
    testoesteso+='<span><A href=# class=news_titolo onClick=\'window.open("./index.php?pArea=1&pAct=shw01&lCod=41","News","widt h=515,height=450"); return false\'>26.09.2005';
    testoesteso+='</div>';
    */
    <?php
    include_once("../inc/db.inc.php");
    $db=@mysql_connect($host,$user,$pass);
    //legge il file che si vuole: apre l'index se non si passa la stringa
    //$campo=!empty($_GET["id"]) ? $_GET["id"] : "200505" ;
    $sql="SELECT file,altro FROM testo WHERE NOT (altro LIKE '%Home%' ) ORDER BY id DESC LIMIT 0,5";
    $result=mysql_db_query($db_name,$sql,$db);
    while ($row=mysql_fetch_array($result))
    {
    //crea il testo sostituendo la sintassi per i link
    $codice_div_scrollabile.="testoesteso+='<div style=\"margin:0 2px 0 2x\"><a href=http://www.joesport.it/index.php?id=".$row["file"]." target=_parent class=NhText>".$row["altro"]."</a></div>
    ';\n";
    }
    mysql_close();
    echo $codice_div_scrollabile;
    ?>

    var testo='';
    if(document.getElementById || document.all){
    testo=testoesteso;
    }
    else {
    testo=testobreve;
    }
    function scrollerObj(name,initH,initW,heightB,widthB,conten t,initBg,Bg,speed,initFl)
    {

    //**data**//
    this.name=name;
    this.initH=initH;
    this.initW=initW;
    this.heightB=heightB;
    this.widthB=widthB;
    this.content=content;
    this.initBg=initBg;
    this.Bg=Bg;
    this.iniFl=initFl;
    this.speed=parseInt(speed);
    this.timer = name + "Timer";
    this.elem;

    //**methods**//
    this.getElement = getElement;
    this.createLayer=createLayer;
    this.scrollLayer = scrollLayer;
    this.scrollLoop=scrollLoop;

    //**initiate methods**//
    this.createLayer();
    this.getElement();
    this.scrollLayer();
    }

    //**call this method to stop scrolling**//
    function scrollLoop(s){
    this.speed = s;
    }

    //**pretty obvious**//
    function scrollLayer(){
    if(document.getElementById || document.all){
    if(parseInt(this.elem.style.top)>(this.elem.offset Height*(-1)+3)){
    this.elem.style.top = parseInt(this.elem.style.top)-this.speed;
    this.timer = setTimeout(this.name+'.scrollLayer()','100');
    }
    else {
    //this.elem.style.top = this.initH;
    this.elem.style.top = 50;
    this.timer = setTimeout(this.name+'.scrollLayer()',3000);
    }
    }
    }

    //**get the specific dom-expression**//
    function getElement(){
    if(document.getElementById){
    this.elem = document.getElementById(this.name);
    }
    else if (document.all){
    this.elem = document.all[name];
    }
    else if (document.layers){
    this.elem = document.layers[name];
    }

    }


    //**pretty obvious - if NS4 - please upgrade to a standard compliant browser**//
    function createLayer(){
    if(document.getElementById || document.all){
    document.write('<div style="position:relative;overflow:hidden;"><div id="layer'+this.name+'" style="position:relative;overflow:hidden;float:'+t his.initFl+';background-color:#'+this.initBg+';border:0;width:'+this.initW +'px;height:'+this.initH+'px;" onMouseover="'+this.name+'.scrollLoop(0)" onMouseout="'+this.name+'.scrollLoop('+this.speed+ ')">');
    //document.write('<div id="'+this.name+'" style="text-align:left;position:absolute;top:'+this.initH+'px; left:0px;border:0;width:'+this.widthB+'px;backgrou nd-color:#'+this.Bg+'">');
    document.write('<div id="'+this.name+'" style="text-align:left;position:absolute;top:100px;left:0px;bo rder:0;width:'+this.widthB+'px;background-color:#'+this.Bg+'">');
    document.write(this.content);
    document.write('<\/div><\/div><\/div>');
    }
    else if(document.layers){
    document.write(this.content);
    return;
    }
    if(this.scrollLayer){
    this.timer = setTimeout(this.name+'.scrollLayer()','100');
    }
    }

  5. #5
    ciao! scusa il ritardo nella risp. Ho potuto lavorare solo oggi. Ho fatto come hai detto. Le miè incomprensioni erano dovute alla struttura della tabella del db. L'ho ricreata con id-file-altro. Ma file a cosa dovrebbe servire?

    Inoltre ho eseguito il codice richiamndolo in una pagina ma niente. Ho preso da esempio la home della del sito che mi hai postato seguendo gli stessi passi.
    La parte dove faccio eseguire lo script rimane vuota.
    Dove sbaglio?
    Ho eseguito solo lo script e nn mi da alcun errore. Mi satmpa quello che c'è nella tabella.
    Di seguito t riporto quello che ho fatto:

    var testoesteso='';
    var testobreve='';
    /*
    testoesteso+='<div style="margin:0 2px 0 2px" >';
    testoesteso+='<span><A href=# class=news_titolo onClick='window.open("./index.php?pArea=1&pAct=shw01&lCod=41","News","widt h=515,height=450"); return false'>';
    testoesteso+='</div>';
    */

    <?
    // Il nome dell'host (hostname) su cui si trova MySQL
    $dbhost = "localhost";

    // Il nome del nostro database
    $dbname = "xxxxx";

    // Il nostro nome utente (username)
    $dbuser = "xxxxx";

    // La nostra password
    $dbpass = "xxxx";

    // Funzione mysql_connect()
    $conn = mysql_connect($dbhost,$dbuser,$dbpass)
    or die("Impossibile collegarsi al server MySQL.");

    // Funzione mysql_select_db()
    mysql_select_db($dbname,$conn)
    or die("Impossibile selezionare il database $dbname");

    $sql="SELECT file,altro FROM testo WHERE NOT (altro LIKE '%Home%' ) ORDER BY id DESC LIMIT 0,5";

    // Esecuzione comando SQL o messaggio di errore
    $res = mysql_query($sql,$conn)
    or die( "Errore: " . mysql_error() );

    //legge il file che si vuole: apre l'index se non si passa la stringa [cosa vuol dire?]
    $campo=!empty($_GET["id"]) ? $_GET["id"] : "200505" ;


    while ($row=mysql_fetch_array($res))
    {
    //crea il testo sostituendo la sintassi per i link
    $codice_div_scrollabile="testoesteso+=".$row["file"].$row["altro"]."
    ;\n";

    }



    echo $codice_div_scrollabile;

    // Funzione mysql_close()
    mysql_close($conn);

    ?>
    var testo='';
    if(document.getElementById || document.all){
    testo=testoesteso;
    }
    else {
    testo=testobreve;
    }
    function scrollerObj(name,initH,initW,heightB,wid
    thB,content,initBg,Bg,speed,initFl)
    {

    //**data**//
    this.name=name;
    this.initH=initH;
    this.initW=initW;
    this.heightB=heightB;
    this.widthB=widthB;
    this.content=content;
    this.initBg=initBg;
    this.Bg=Bg;
    this.iniFl=initFl;
    this.speed=parseInt(speed);
    this.timer = name + "Timer";
    this.elem;

    //**methods**//
    this.getElement = getElement;
    this.createLayer=createLayer;
    this.scrollLayer = scrollLayer;
    this.scrollLoop=scrollLoop;

    //**initiate methods**//
    this.createLayer();
    this.getElement();
    this.scrollLayer();
    }

    //**call this method to stop scrolling**//
    function scrollLoop(s){
    this.speed = s;
    }

    //**pretty obvious**//
    function scrollLayer(){
    if(document.getElementById || document.all){
    if(parseInt(this.elem.style.top)>(this.elem.offset Height*(-1)+3)){
    this.elem.style.top = parseInt(this.elem.style.top)-this.speed;
    this.timer = setTimeout(this.name+'.scrollLayer()','100');
    }
    else {
    //this.elem.style.top = this.initH;
    this.elem.style.top = 50;
    this.timer = setTimeout(this.name+'.scrollLayer()',3000);
    }
    }
    }

    //**get the specific dom-expression**//
    function getElement(){
    if(document.getElementById){
    this.elem = document.getElementById(this.name);
    }
    else if (document.all){
    this.elem = document.all[name];
    }
    else if (document.layers){
    this.elem = document.layers[name];
    }

    }


    //**pretty obvious - if NS4 - please upgrade to a standard compliant browser**//
    function createLayer(){
    if(document.getElementById || document.all){
    document.write('<div style="position:relative;overflow:hidden;"><div id="layer'+this.name+'" style=" position:relative;overflow:hidden;float:
    '+this.initFl+';background-color:#'+this.initBg+';border:0;width:'+this.initW +'px;height:'+this.initH+'px;" onMouseover="'+this.name+'.scrollLoop(0)" onMouseout="'+this.name+'.scrollLoop('+this.speed+ ')">');
    //document.write('<div id="'+this.name+'" style="text-align:left;position:absolute;top:'+this. initH+'px;left:0px;border:0;width:'+this
    .widthB+'px;background-color:#'+this.Bg+'">');
    document.write('<div id="'+this.name+'" style="text- align:left;position:absolute;top:100px;l
    eft:0px;border:0;width:'+this.widthB+'px;backgroun d-color:#'+this.Bg+'">');
    document.write(this.content);
    document.write('<\/div><\/div><\/div>');
    }
    else if(document.layers){
    document.write(this.content);
    return;
    }
    if(this.scrollLayer){
    this.timer = setTimeout(this.name+'.scrollLayer()','100');
    }
    }
    "fate bene l'ordinario in modo straordinario!"

  6. #6
    Hai messo le password giuste vero? Come hai chiamato il file? SE è un .php prova a chiamrlo dal browser e vedi che testo crea. Al limite ci sentiamo in privato.....

  7. #7
    grazie lo stesso! fa niente! ho risolto con i marquee. Ho creato un codice che prende le news da una tabella e poi faccio uno scroll del report ottenuto! Funziona bene! Devo ora ottimizzare la parte di amministrazione x l'inserimento delle news!
    "fate bene l'ordinario in modo straordinario!"

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.