0

So I have in my website a table of clients with several columns such as name, age, etc, etc... and I have added a new column which is "Delete" and I added checkboxes, and there's also a button, what I want to do is, if I select one or more checkboxes, and then click on the button to delete, I want them to be deleted off the website but then on the database I want to a field to be updated from 0 to 1 whereas 0 means the client exists on both website and database and 1 means that it no longer exists on the website but it still exists on database.

I'm new in the area of programming but this is the code I got so far:

$checkboxes = isset($_POST['option'])? $_POST['option']: array();

foreach($checkboxes as $value){

  $query = "UPDATE commande

  SET traiter = 1

  WHERE id = $value";

  mysql_query($query);

  var_dump($query);

}

Now when I execute that, the var_dump appears to be correct, the var_dump returns me the expected, but when I check database, I see that it didn't update the field "traiter" to = 1

So I'm kinda confused and lost, anyone can help me out here with this?

Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
Le Future
  • 1
  • 1
  • 1
    Please [stop using `mysql_*` functions](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php). [These extensions](http://php.net/manual/en/migration70.removed-exts-sapis.php) have been removed in PHP 7. Learn about [prepared](http://en.wikipedia.org/wiki/Prepared_statement) statements for [PDO](http://php.net/manual/en/pdo.prepared-statements.php) and [MySQLi](http://php.net/manual/en/mysqli.quickstart.prepared-statements.php) and consider using PDO, [it's really pretty easy](http://jayblanchard.net/demystifying_php_pdo.html). – Jay Blanchard Dec 08 '15 at 14:25
  • You need to do some error checking on your queries or check your error logs. You'll likely find the answers there. – Jay Blanchard Dec 08 '15 at 14:27
  • 1
    Add error reporting to the top of your file(s) right after your opening PHP tag for example ` – Funk Forty Niner Dec 08 '15 at 14:27
  • *Yep Ralph. Sure is.* @Fred-ii- – Jay Blanchard Dec 08 '15 at 14:28
  • 1
    Try var_dump($value) .. into foreach loop .. to check the values of $value – Aniruddha Chakraborty Dec 08 '15 at 14:28

0 Answers0