0

I want to use 1 field for data positioning in table and that must be auto incremented

public function DBInsert($table_name, $form_data){
    // retrieve the keys of the array (column titles)
    $fields = array_keys($form_data);// build the query
    $sql = "INSERT INTO ".$table_name.".(`".implode('`,`', $fields)."`)VALUES('".implode("','", $form_data)."')";
    //echo $sql;// run and return the query result resource return  
    mysql_query($sql) or die(mysql_error());
}
RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
  • 2
    Ok, thanks for sharing, but what is the question please – RiggsFolly Jul 12 '17 at 11:45
  • 2
    Every time you use [the `mysql_`](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php) database extension in new code **[this happens](https://media.giphy.com/media/kg9t6wEQKV7u8/giphy.gif)** it is deprecated and has been for years and is gone for ever in PHP7. If you are just learning PHP, spend your energies learning the `PDO` or `mysqli` database extensions and prepared statements. [Start here](http://php.net/manual/en/book.pdo.php) – RiggsFolly Jul 12 '17 at 11:46

0 Answers0