PHP jQuery script modification/correction
<p>i have on page this table:</p>

<p><img src="http://i.stack.imgur.com/BsjL2.jpg" alt="enter image description here"></p>

<p>It's just result of query that returns records belonging to current user.
I added delete button. </p>

<p>I'm jquery&amp;ajax <strong>newbie</strong> and i invented this task to myself.
I wanted to handle button using these technologies.
It should delete one row in table.</p>

<p>With my weak skills i could do this only in 1 way</p>

<pre><code>    $user=$_SESSION['userid'];
    $con = db_connect();

    $result = $con-&gt;query("SELECT  `id_app`, `date_cr`,`id_user`
                            FROM `applications`
                            WHERE id_user = $user");
    if(($data = $result-&gt;num_rows)==0){
            echo '&lt;p class="error"&gt;No data&lt;/p&gt;';                
            exit;
    }
    else
    {           
        echo '&lt;script type="text/javascript" 
        src="./functions/jquery-1.7.1.min.js"&gt;&lt;/script&gt;';   

        echo '&lt;br/&gt;&lt;br/&gt;&lt;table id="tab_history"&gt;
        &lt;tr&gt;&lt;td&gt;Time when created&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;';

        while(($data = $result-&gt;fetch_assoc())!==null)
        {
            echo '&lt;tr&gt;';
            echo '&lt;td&gt;'.$data['date_cr'].'&lt;/td&gt;&lt;td&gt;';
            echo '&lt;button id="btnDel'.$data['id_app'].'" type="button"&gt;
            Delete&lt;/button&gt;&lt;/td&gt;&lt;/tr&gt;';

            echo '
            &lt;script type="text/javascript"&gt;
            $("#btnDel'.$data['id_app'].'").click(function (e) { 
                e.preventDefault();

                if (confirm(\'Are you sure?\')){
                    var id_app = '.$data['id_app'].';
                    var id_user = '.$data['id_user'].';

                    var info = \'id_app=\'+id_app+\'&amp;id_user=\'+ id_user;

                    $.ajax({
                       type: "POST",
                       url: "./functions/del_app.php",
                       data: info,
                       success: function(){                             
                        location.reload();                          
                        }   
                    });                                         
                }                     
                });         
            &lt;/script&gt;'; 
        }
        echo '&lt;/table&gt;';
    }
</code></pre>

<p>It's fine, it's deleting, so i don't attach function file. </p>

<p>But it's really stupid method:P. I'm adding script to each row. I have been thinking how to make it with one script but had no idea. Maybe button class?</p>

<p>I really would like to know how to get the same effect with one script leaving buttons.</p>

<p>Thx in advance.</p>
