php - How to add row in table and in mysql using button or link? -
i'm creating simple database of children , birthday.
<?php $chname1x = mysql_real_escape_string($_post["chname1"]); $chbdate1x = mysql_real_escape_string($_post["chbdate1"]); $chname2x = mysql_real_escape_string($_post["chname2"]); $chbdate2x = mysql_real_escape_string($_post["chbdate2"]); $chname3x = mysql_real_escape_string($_post["chname3"]); $chbdate3x = mysql_real_escape_string($_post["chbdate3"]); $chname4x = mysql_real_escape_string($_post["chname4"]); $chbdate4x = mysql_real_escape_string($_post["chbdate4"]); $chname5x = mysql_real_escape_string($_post["chname5"]); $chbdate5x = mysql_real_escape_string($_post["chbdate5"]); $dbhost='localhost'; $dbuser='root'; $dbpass=''; $conn=mysql_connect($dbhost,$dbuser,$dbpass) or die ('could not connect mysql'); $dbname='onlinepdsdb'; mysql_select_db($dbname); if ($_post['submitbutton']) { $query="insert children (chname1,chbdate1,chname2,chbdate2,chname3,chbdate3,chname4,chbdate4,chname5,chbdate5) values ('$chname1x', '$chbdate1x','$chname2x', '$chbdate2x','$chname3x', '$chbdate3x','$chname4x', '$chbdate4x','$chname5x', '$chbdate5x')"; mysql_query($query) or die (mysql_error()); echo "the user $uid has been succesfully registered."; echo $query; echo $uid; } <center> <form method='post' action='formchildren.php'> <table border='3' style='width:700px'> <tr bgcolor='#3399ff'> <td colspan='2' class='head2' height='20'>name of child (write full name , list all)</td> <td colspan='3' class='head2' height='20'>date of birth (mm/dd/yyyy)</td> </tr> <tr> <td class='numbering'>1.</td> <td style='text-align:center;'> <input type='text' name='chname1' size='45' maxlength='200'> </td> <td style='text-align:center;'> <input type='date' name='chbdate1' size='45' maxlength='50'> </td> </tr> <tr> <td colspan=6 class='step' height='10'></td> </tr> <tr> <td class='numbering'>2.</td> <td style='text-align:center;'> <input type='text' name='chname2' size='45' maxlength='200'> </td> <td style='text-align:center;'> <input type='date' name='chbdate2' size='45' maxlength='50'> </td> </tr> <tr> <td colspan=6 class='step' height='10'></td> </tr> <tr> <td class='numbering'>3.</td> <td style='text-align:center;'> <input type='text' name='chname3' size='45' maxlength='200'> </td> <td style='text-align:center;'> <input type='date' name='chbdate3' size='45' maxlength='50'> </td> </tr> <tr> <td colspan=6 class='step' height='10'></td> </tr> <tr> <td class='numbering'>4.</td> <td style='text-align:center;'> <input type='text' name='chname4' size='45' maxlength='200'> </td> <td style='text-align:center;'> <input type='date' name='chbdate4' size='45' maxlength='50'> </td> </tr> <tr> <td colspan=6 class='step' height='10'></td> </tr> <tr> <td class='numbering'>5.</td> <td style='text-align:center;'> <input type='text' name='chname5' size='45' maxlength='200'> </td> <td style='text-align:center;'> <input type='date' name='chbdate5' size='45' maxlength='50'> </td> </tr> <tr><input type='submit' name='submitbutton'></tr> </table> </form>
i created here 5 rows, if children more 5 there no more rows. want put link/button if clicked add row in table , in mysql don't have idea how.
you can use jquery
.append()
here source jquery append
using append: e.g. click button, can append textbox , dropdown list
it's in on how can this.. tip. ;)
example here:
Comments
Post a Comment