John Davidson

php - update specific field data on sql database

0 comments
Message:


so i have a table of data in web ui



as soon as I click the button. all of the field data in "Status Email" changed. not just selected field that i meant.
this is the sintaks sql


if($mail->Send())
{
$query = "UPDATE nearly_inactive SET EmailSent = 'Sudah Kirim Email' WHERE EmailSent = 'Belum Kirim Email'";
$update = $con->prepare($query);
$update->execute();
}

how can i get the "update" only the data that I click on the button??



My Answer:
You can achieve this by adding a condition to your SQL query to update only the specific field data that you want. You can pass the specific field data that you want to update as a parameter to your query.

Here is an example of how you can modify your SQL query to update only the specific field data that you click on the button:

php
if($mail->Send())
{
$specificFieldData = "specific data"; // This is the specific field data that you want to update
$query = "UPDATE nearly_inactive SET EmailSent = 'Sudah Kirim Email' WHERE EmailSent = 'Belum Kirim Email' AND SpecificField = :specificFieldData";
$update = $con->prepare($query);
$update->bindParam(':specificFieldData', $specificFieldData);
$update->execute();
}


In this example, you need to replace "specific data" with the actual specific field data that you want to update. This way, the SQL query will only update the field data that matches the specific field data that you pass as a parameter.

Rate this post

3 of 5 based on 8487 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us