Visualizzazione dei risultati da 1 a 8 su 8

Discussione: shift update

  1. #1

    shift update

    Buongiorno a tutti,

    ho la seguente tabella iniziale
    codice HTML:
    id          id_utente                  
    1                10
    2                14
    3                16
    Dovrei far in modo che ogni volta alla pressione di un pulsante avvenga un Update della tabella e il campo id_utente sciffiti di 1 posizione ovvero

    codice HTML:
    id          id_utente                  
    1                16
    2                10
    3                14

    Qualche suggerimento?

  2. #2

  3. #3
    Ad oggi si, ma nulla vieta che domani possano essere tre oppure 2 o 4

  4. #4
    e vale sempre la regola che il valore del primo shifta verso il basso e il primo prende il valore dell'ultimo (cioè, in pratica ruotano)?

  5. #5
    si

  6. #6
    ma è una tabella a video o una tabella di database?

  7. #7
    database

  8. #8
    Sarà un pò macchinoso, ma ho risolto

    Codice PHP:
    $query_Recordset7 "SELECT * FROM appuntamento_randomico ORDER BY id_randomico DESC LIMIT 0, 1";
    $Recordset7 mysql_query($query_Recordset7$aic) or die(mysql_error());
    $row_Recordset7 mysql_fetch_assoc($Recordset7);
    $totalRows_Recordset7 mysql_num_rows($Recordset7);
    $ultimo_id_insert_random=$row_Recordset7['id_utente'];

    $query_c "SELECT * FROM appuntamento_randomico";
    $Recordset_c mysql_query($query_c$aic) or die(mysql_error());
    $totalRows_c mysql_num_rows($Recordset_c);
    while(
    $row_c=mysql_fetch_row($Recordset_c))
    {
                         
    $id_rand=$row_c[0];
                         
    $id_utente_rand=$row_c[1];
                        
                        

    for(
    $rr=1$rr<=$totalRows_c$rr++) {    

    $hh=$id_rand+1;

    $update_utente_random "UPDATE appuntamento_randomico SET id_utente='$id_utente_rand' WHERE id_randomico='$hh'";
    mysql_select_db($database_aic$aic);
    $Result_update_utente_random mysql_query($update_utente_random$aic) or die(mysql_error());

    if(
    $Result_update_utente_random) {
    $update_utente_random_ultimo "UPDATE appuntamento_randomico SET id_utente='$ultimo_id_insert_random' WHERE id_randomico='1'";
    mysql_select_db($database_aic$aic);
    $Result_utente_random_ultimo mysql_query($update_utente_random_ultimo$aic) or die(mysql_error());
    } else {} 
    }        
                         } 

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.