Visualizzazione dei risultati da 1 a 3 su 3

Discussione: Checkbox checked

  1. #1

    Checkbox checked

    ho la seguente form:
    Codice PHP:
      $query mysql_query("SELECT * FROM attack ORDER BY numattack DESC");

      echo 
    "Tentativi di attacco bloccati:
    "
    ;
      echo 
    "<form action='index.php?act=attack&op=edit' method='post'>";

      echo 
    "<table align='center' border='1'>";
      echo 
    "<tr><td align='center'>IP</td><td>N° tentativi</td><td>Ban</td></tr>";
      while(
    $echo mysql_fetch_array($query)){

        echo 
    "<tr><td>".$echo[1]."<td align='center'>".$echo[3]."</td><td align='center'>";
        if(
    $echo[2] == 0){echo "<input type='checkbox' name='".$echo[0]."'>";}
        else{echo 
    "<input type='checkbox' name='".$i."' checked>";}
        echo 
    "</td></tr>";
      } 
    che rimanda a questo script
    Codice PHP:
      $query mysql_query("SELECT COUNT(*) FROM attack");
      
    $echo mysql_fetch_array($query);
      for(
    $i 1$i <= $echo[0]; $i++){
      if(
    $_POST[$i] == false){$ban 0;}
      else{
    $ban 1;}
      
    mysql_query("UPDATE attack SET ban='".$ban."' WHERE id='".$i."'");
      }
      echo 
    "Aggiornamento ban effettuato con successo."
    la checkbox e' spuntata quando e' effettivamente 1 nel database, ma quando lascio inalterate le checkbox spuntate automaticamente e clicko su modifica quando torno sulle checkbox sono non spuntate, e nel db il valore e' 0

    che sia un problema di browser o di php che non riconosce come true le checkbox con attributo checked ?

  2. #2
    chiedo scusa... errore di battitura.

  3. #3

    Checkbox checked

    Ciao pop killer
    scorrendo il forum ho trovato casualmente il tuo script per una funzione che devo applicare ad una checkbox in un form di modifica.

    Ho visto che poi hai risolto tu scrivendo che c'era un errore di battitura.

    Non è che saresti così gentile da svelare il segreto alla comunità?

    Ti posto in ogni caso lo scritto.
    Nel form è:
    if($result[9] == 0)
    {
    echo "<input type='checkbox' name='".$result[0]."'>";}
    else{
    echo "<input type='checkbox' name='".$i."' checked>";}

    echo " </tr>\n";

    La query é:

    for($i = 1; $i <= $result[0]; $i++){
    if($_POST[$i] == false){$News_Bool = 0;}
    else{$News_Bool = 1;}
    mysql_query("UPDATE $table6 SET News_Bool='".$News_Bool."' WHERE News_ID='".$i."'");
    }


    Ti ringrazio infinitamente.

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.