php - Get a table that can change data directly -


i want data create table can edit,that means data in database can shown in input type box , user can change directly in table.

here code: in code name , dob(date of born) , tel. want these data show in text boxes in way allows direct edition of these data.

<?php    $con = mysql_connect("127.0.0.1","root","password");   mysql_select_db("school2");   $sql = "select * student";   $results = mysql_query($sql,$con);    echo "<table border=1 cellpadding=10>";   echo "<tr><th>sid</th><th>name</th><th>dob</th><th>tel</th></tr>";   while($row = mysql_fetch_array($results)) {      echo "<tr>             <td>$row[0]</td>             <td>$row[1]</td>             <td>$row[2]</td>             <td>$row[3]</td>           </tr>";    }   echo "</table>"; ?> 

if target text boxes, changes :

 echo "<tr>             <td>$row[0]</td>             <td>$row[1]</td>             <td>$row[2]</td>             <td>$row[3]</td>           </tr>"; 

to

echo "<tr>         <td><input type=text id='row0' name='row0' value='$row[0]' /></td>         <td><input type=text id='row1' name='row1' value='$row[1]' /></td>         <td><input type=text id='row2' name='row2' value='$row[2]' /></td>         <td><input type=text id='row3' name='row3' value='$row[3]' /></td>      </tr>"; 

after this, you'll need submit / update button, onclick, fetches these values above table , updates corresponding record in database


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -