How to insert data from database using oops php concepts?
<p>I try to insert one person detail, it's inserted successfully. If i check in DB "same data insert 3 times".  Why the data insert 3 times? </p>

<p>I had this data in the Database.</p>

<pre><code>id      name       dob             gen
1       James     12-03-1977        M
2       James     12-03-1977        M
3       James     12-03-1977        M
</code></pre>

<p>PHP class </p>

<pre><code>class Detail
{
function savePerson_detail($vars){
    foreach($vars as $key =&gt; $value){
       if(is_numeric($key) &amp;&amp; $value &gt;0){
         $qry = sprintf("INSERT INTO cca_student_list(per_name, per_dob, per_gen) VALUES('%s', '%s', '%s')",
        mysql_real_escape_string($vars['name']),
        mysql_real_escape_string($vars['dob']),
        mysql_real_escape_string($vars['gen']));
        mysql_query($qry) or die(mysql_error());
         if($qry)
    {
    print 'Successfully Insert your details';
    }
   }
}
</code></pre>

<p>Html Page</p>

<pre><code>&lt;?php
$detail = new Detail();
if(isset($_POST['btnSaveDetail'])){
   $detail-&gt;savePerson_detail($_POST);
}?&gt;
</code></pre>
