title: how to make an insert function with in a database class to insert a new record with multiple coloumns and multiple values (using PDO )?
body: <p>the problem is my function <em>insert</em> inserts my record in two rows.</p>
  
  <p>this is my code to connect to database in a file named :</p>
  
  <p><strong>connect.php</strong></p>
  
  <pre><code>&lt;?php
  try{
  $db = new PDO("mysql:host=localhost;dbname=NPD" , "root" , "");
  
  echo "connected";
  }
  catch(Exception $e){
      echo $e-&gt;getMessage();
  }
  </code></pre>
  
  <p>this is my database class in a file</p>
  
  <p><strong>database.php</strong></p>
  
  <pre><code>&lt;?php
  
  require 'connect.php';
  class DB {
  public function insertInto($tableName , $info){
          global $db;
          foreach ($info as $coloumnName =&gt; $coloumnValue) {          
              $stmt = $db-&gt;prepare("INSERT INTO $tableName ($coloumnName) VALUES ('$coloumnValue') ");
              $stmt-&gt;execute();   
          }
      }
  }
  $da = new DB;
  $da-&gt;insertInto('tableOne',array('name' =&gt; 'lolo' , 'deg' =&gt; '100'));
  </code></pre>
  
  <p>the result in the database is :
  <a href="http://i.stack.imgur.com/NYLwv.jpg" rel="nofollow">tableOne</a></p>
  
  <p>how can to make the <em>insert</em> function inserts my record in one row.</p>
  
  <p><em>note</em> : i want to insert any number of columns and values.</p>