lundi 22 mai 2017

While loop Mysql updating checkboxes where to start

I have a question how can I update the database if person unchecks or check a checkbox and update the boolean field in mysql? For days stuck with this problem, because problem I don't know how to make a form or check if it is validate inside of a while loop here is my code:

<?
    $result= mysql_query("SELECT * FROM cars");
    $counter = 1;

    while($row = mysql_fetch_array($result)) { 
        echo '<tr>
            <td>' . $counter++ . '</td>
            <td><input type="checkbox"';  
            if ($row['show'] == true) {  
                echo 'checked></td>'; 
            } else { 
                echo 'unchecked></td>'; 
            }
            echo '<td><img src="../xml/'.$row['cars_id'].'-1.JPG"  width="120px"></td>';        
            echo "<td><h3> ", $row['brand']," " . $row['model'], " " . $row['type'], 
             " &euro; " . $row['price'], " </h3></td>";
        echo '</tr>';
    }
?>

p.s. I am aware of the mysql to mysqli or pdo but it is a HUGE script...




Aucun commentaire:

Enregistrer un commentaire