button - PHP Delete products / ID -


so have this:

    echo "         <form action='users/delete.php' method='post'>           <input type='hidden' name='productid' value='".$row->productid."' />           <input type='submit' value='delete' />         </form>     "; 

this comes under every item on webshop: webshop

that works, whenever press button table not being deleted, delete.php

<?php  define('_host_name_', 'localhost'); define('_user_name_', 'root'); define('_db_password', '#####'); define('_database_name_', 'ws_webshop');  //pdo database connection try {  $databaseconnection = new pdo('mysql:host='._host_name_.';dbname='._database_name_, _user_name_, _db_password);  $databaseconnection->setattribute(pdo::attr_errmode, pdo::errmode_exception); } catch(pdoexception $e) {  echo 'error: ' . $e->getmessage(); }       // create pdo instance; assign $db variable     $sql = "delete `tbl_products` `productid` = :productid limit 1";     $smt = $databaseconnection->prepare($sql);     $smt->bindparam(':productid', $_post['productid'], pdo::param_int);     $smt->execute();  header('location: ../webshop.php'); 

but doesnt remove it, see problem? thanks!

your $row usage object, have array. either change fetch to:

->fetch(pdo::fetch_obj); 

-http://php.net/manual/en/pdostatement.fetch.php

or change usage to:

echo "         <form action='users/delete.php' method='post'>           <input type='hidden' name='productid' value='".$row['productid'] . "' />           <input type='submit' value='delete' />         </form>     "; 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

android - Keyboard hides my half of edit-text and button below it even in scroll view -