2017-10-18 71 views
-1

我在任務項目上工作,那就是在數據庫(MySQL)中輸入任務的輸入,然後在web中顯示輸入。現在我有了MySQL的每個ID的複選框。我想如果複選框被勾選按下按鈕,MySQL任務中的更新結束,但問題是這裏如何告訴每個ID更新不同的值。我的意思是在任務是「結束」或任務是「Not_Over」。如何使用不同的ID在MySQL中更新CheckBox

+0

你有一些代碼 –

回答

0

是內博伊沙我..下面你可以看到我的代碼 現在我想在MySQL更新此爲WACH ID separete

<html> 
<head> 
<title> 
Task 
</title> 
</head> 
<body> 
<?php 
$servername = "localhost"; 
$username = "root"; 
$password = "123456789"; 
$db="task_db"; 

// Create connection 
$conn = new mysqli($servername, $username, $password, $db); 

    // Check connection 
    if ($conn->connect_error) { 
    die("Connection failed: " . $conn->connect_error); 
    } 
    echo "Konektovan na bazu MySQL<br>"; 
    ?> 
    <a href="add_a_new_task.php">ADD a new Task</a> | <a 
    href="review_tasks.php">Show Task</a> | <a 
    href="completed_tasks.php">Ended Task</a> 
    <hr> 


<?php 

    $Select = "SELECT * FROM tasks WHERE done LIKE 'NE'"; 
    $Result = $conn->query($Select); 


    echo '<table align="center" style="width:65%" border="2"> 
    <tr> 
    <th>O.R.</th> 
    <th>Name and LastName</th> 
    <th>Phone Number</th> 
    <th>Places</th> 
    <th>Task</th> 
    <th>Notes</th> 
    <th>Executes</th> 
    <th>Executed</th> 
    <th>Created day</th> 
    <th><input type="submit" name="add_task" value="Update Tasks"></th> 
    </tr>'; 
    if ($Result->num_rows > 0) { 
    // output data of each row 
    while($row = $Result->fetch_assoc()) { 
     $id = $row['ID']; 
     echo "<td> RB</td>"; 
     echo "<td>".$row["Name_and_Lastname"]."</td>"; 
     echo "<td>".$row["Phone_Number"]."</td>"; 
     echo "<td>".$row["Place"]."</td>"; 
     echo "<td>".$row["Task"]."</td>"; 
     echo "<td>".$row["Note"]."</td>"; 
     echo "<td>".$row["Executes"]."</td>"; 
     echo "<td>".$row["Done"]."</td>"; 
     echo "<td>".$row["Created_Date"]."</td>"; 
     echo "<td><input type='checkbox' name='vehicle' 
     value='task'>Finish</td>"; 
     echo "</tr>"; 
     } 
      } else { 

     echo "<tr><th colspan='4'>0 results</th></tr>"; 
     } 
     echo "</table>"; 



     $conn->close(); 

     ?> 

     </body> 
     </html>