Visualizzazione dei risultati da 1 a 7 su 7

Discussione: help controllo script

  1. #1
    Utente di HTML.it
    Registrato dal
    Jul 2010
    Messaggi
    22

    help controllo script

    Ciao a tutto il forum volevo un aiutino per sapere se ho scritto bene una funzione perchè non mi funziona
    Codice PHP:
     $sql "SELECT `BPPENNYAUTOBID_auctions`.`suspended`\n FROM BPPENNYAUTOBID_auctions\n"
             
    $resrow mysql_fetch_row($result);  
             
    $suspended $resrow;         
              if (
    $suspended == 1)
     {     
    sleep(10);    
      } 
    Grazie a tutti

  2. #2
    $result cos'è?
    CODENCODE \ Branding \ Design \ Marketing
    www.codencode.it

  3. #3
    Utente di HTML.it
    Registrato dal
    Jul 2010
    Messaggi
    22
    riposto il codice che ho provato a modificare ma senza successo sigh
    Codice PHP:
     $myconn mysql_connect('localhost','astapert','*********');
      
    mysql_select_db('astapert_astapertutti',$myconn);   
      
    $query "SELECT suspended, FROM BPPENNYAUTOBID_auctions";
      
    $result mysql_query($query,$myconn);
             
    $resrow mysql_fetch_row($result);
             
    $suspended $resrow;
             if (
    $suspended == 1) {
         
    sleep(10);
         } 
    Comunque il mio problema è il seguente se utilizzo sleep (10) mi ritarda tutto io vorrei invece che mi ritardasse solo le aste sospese nella tabella suspended quindi quando trova il valore 1 mi parte lo sleep
    grazieeee

  4. #4
    sleep(10) non fa altro che attendere attende 10 secondi, dopo di che riprende l'esecuzione dello script.
    CODENCODE \ Branding \ Design \ Marketing
    www.codencode.it

  5. #5
    Utente di HTML.it
    Registrato dal
    Jul 2010
    Messaggi
    22
    si in questo caso ho messo 10 sec è un esempio ma a me interessa che mi vada a ritardare solo quelle suspended come faccio a prelevare il valore 1 che viene attribuito nel db quando appunto sono suspended?

  6. #6
    Ma cosa intendi per "ritardare le suspended"?
    sleep() agisce sullo script php, non è che ti ritarda altro.
    CODENCODE \ Branding \ Design \ Marketing
    www.codencode.it

  7. #7
    Utente di HTML.it
    Registrato dal
    Jul 2010
    Messaggi
    22
    Codice PHP:
       $myconn = mysql_connect('localhost','astapert','*********');
      mysql_select_db('astapert_astapertutti',$myconn);   
      $query = "SELECT suspended, FROM BPPENNYAUTOBID_auctions";
      $result = mysql_query($query,$myconn);
             $resrow = mysql_fetch_row($result);
             $suspended = $resrow;
             if ($suspended == 1) {
         sleep(10);
         }
            for($i=0; $i<$total_elements; $i++){
              echo "myTimeArray[".$i."] = myTimeArray[".$i."] + CountStepper;";    
            }
            for($i=0; $i<$total_elements; $i++){
              echo "secs = myTimeArray[".$i."];";
              
              
              echo "DisplayStr = DisplayFormat.replace(/%%D%%/g, calcage(secs,86400,1000000));";
              echo "DisplayStr = DisplayStr.replace(/%%H%%/g, calcage(secs,3600,24));";
              echo "DisplayStr = DisplayStr.replace(/%%M%%/g, calcage(secs,60,60));";
              echo "DisplayStr = DisplayStr.replace(/%%S%%/g, calcage(secs,1,60));";
              echo "if(secs < 0){
                      if(document.getElementById('el_type_".$i."').value == '1'){
                        document.getElementById('el_".$i."').innerHTML = FinishMessage1;                      
                      }else{
                        document.getElementById('el_".$i."').innerHTML = FinishMessage2;";
                        if(!$TPL_is_auction_started[$i]){ echo "setTimeout(\"document.location.href = 'index.php';\",5000);"; }
              echo "  }";                  
              echo "}else{";
              echo " document.getElementById('el_".$i."').innerHTML = DisplayStr;";        
              echo "}";
            }
          ?>        
      if (CountActive) setTimeout("CountBack()", SetTimeOutPeriod);
    }

    function putspan(backcolor, forecolor, id) {
      document.write("<span id='"+ id +"' style='font-size:18px;color:#000044;background-color:" + backcolor + "; color:" + forecolor + "'></span>");
    }

    if (typeof(BackColor)=="undefined")     BackColor = "white";
    if (typeof(ForeColor)=="undefined")     ForeColor= "black";
    if (typeof(TargetDate)=="undefined")    TargetDate = "12/31/2020 5:00 AM";
    if (typeof(DisplayFormat)=="undefined") DisplayFormat = "%%H%% , %%M%%, %%S%%.";
    if (typeof(CountActive)=="undefined")   CountActive = true;
    if (typeof(FinishMessage)=="undefined") FinishMessage = "";
    if (typeof(CountStepper)!="number")     CountStepper = -1;
    if (typeof(LeadingZero)=="undefined")   LeadingZero =true;


    CountStepper = Math.ceil(CountStepper);
    if (CountStepper == 0) CountActive = false;
    var SetTimeOutPeriod = (Math.abs(CountStepper)-1)*1000 + 990;
    var myTimeArray = new Array();

    <?
      
    for($i=0$i<$total_elements$i++){
    ?>
    /* dthen = new Date(document.getElementById('el_time_'+<?=$i;?>).value); 
      dnow = new Date();
      if(CountStepper>0){ 
        ddiff = new Date(dnow-dthen);
      }else{
        ddiff = new Date(dthen-dnow);
      }*/
      ddiff=document.getElementById('el_sec_'+<?=$i;?>).value;
      //myTimeArray[<?=$i;?>] = Math.floor(ddiff.valueOf()/1000);
      myTimeArray[<?=$i;?>]=Number(ddiff);
    <? ?>        

    CountBack();
        
    </script>
    <script src="js/ajax.js" type="text/javascript"></script>
    <script type="text/javascript"><!--
    numOfElements = <?php echo intval($total_elements); ?>;
    objIdsToElements = Object();
    arr_blinking = Object();
    blink_incr = Object();
    arr_colors = Object();
    step = 25;
    interv = 25;


    function updateBids()
    {
        var str_auctions = "", n;
        // all auctions
        for(el_ind = 0; el_ind < numOfElements; el_ind++)
        {
            arr_colors[el_ind] = 0;
            if(el_ind > 0) str_auctions +=",";
            if(document.getElementById("auction_id_" + el_ind))
            {
                n = document.getElementById("auction_id_" + el_ind).value;
                str_auctions += n;
                // save an index of the element with auction id
                objIdsToElements[n] = el_ind;
            }
        }
        //alert("get_current_bids.php", "param=" + str_auctions);
        abc_runAjax("get_current_bids.php", "param=" + str_auctions);
        
    }

    function processResponse(txt)
    {    
        var sss = txt.split("---");
        if (sss.length==5) {
            var arr_ids = sss[0].split('___');
            var arr_bids = sss[1].split('___');
            var arr_ends = sss[2].split('___');
            var arr_next_bids = sss[3].split('___');
            var arr_winners = sss[4].split('___');
            var el_auction, el_curbid, el_main, el_curbidmain;
            
            // all auctions
            for(j = 0; j < numOfElements; j++)
            {
                el_auction = document.getElementById("auction_id_" + objIdsToElements[arr_ids[j]]);        
                el_curbid = document.getElementById("current_bid_" + objIdsToElements[arr_ids[j]]);
                el_nextbid = document.getElementById("next_bid_" + objIdsToElements[arr_ids[j]]);
                el_winner = document.getElementById("winner_" + objIdsToElements[arr_ids[j]]);
                document.getElementById("hidden_new_bid_" + objIdsToElements[arr_ids[j]]).innerHTML=arr_bids[j];
                arr_bids[j]=document.getElementById("hidden_new_bid_" + objIdsToElements[arr_ids[j]]).innerHTML;
                
                if(el_curbid.innerHTML != arr_bids[j])
                {
                    el_curbid.innerHTML = arr_bids[j];
                    el_nextbid.innerHTML = arr_next_bids[j];
                    el_winner.innerHTML = arr_winners[j];
                    arr_colors[arr_ids[j]] = 255;
                    blink_incr[arr_ids[j]] = step * -1;
                    arr_blinking[arr_ids[j]] = setInterval("blink(" + arr_ids[j] + ")", interv);
                } 
                myTimeArray[objIdsToElements[arr_ids[j]]]=Number(arr_ends[j]);
            }
        }
    }



    function blink(num)
    {
        var el;
        el = document.getElementById("current_bid_" + objIdsToElements[num]);
        arr_colors[num] += blink_incr[num];
        if(arr_colors[num] < 255 && arr_colors[num] > 0)
        {
            el.style.backgroundColor = "rgb(255, "+arr_colors[num]+", "+arr_colors[num]+")";
        }
        else if(arr_colors[num] <= 0)
        {
            arr_colors[num] = 0;
            blink_incr[num] = step;
        }
        else if(arr_colors[num] >= 255)
        {
            arr_colors[num] = 255;
            blink_incr[num] = step * -1;
            clearInterval(arr_blinking[num]);
        }    
    }

    setInterval("updateBids()", 1000);
    questa è la funzione che mi fa partire un countdown su ogni prodotto messo in asta,se metto sleep (10) all'inizio mi ritarda la partenza del countdown sleep mi interviene solo per ritardarmi l'esecuzione di questa funzione ma cosi facendo mi ritarda tutti i countdown mentre io vorrei applicare il ritardo solo alle aste sospese (suspended) quindi avrei l'asta attiva col suo countdown mentre l'asta sospesa col countdown sospeso spero ora sia stato chiaro

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 © 2024 vBulletin Solutions, Inc. All rights reserved.