Click here to Skip to main content
14,427,846 members
Rate this:
Please Sign up or sign in to vote.
hello friends,

im using following code to insert data in database using dynamic text box. its work excellent but now i want to submit data in database without refresh page.
kindly advise what and where i change my code.
plz help. thanks in advance :)


<pre lang="PHP"><?php





$conn = mysql_connect("localhost","root","");


$itemCount = count($_POST["item_name"]);


$query = "INSERT INTO invoice (name,description,quantity) VALUES ";

$queryValue = "";

for($i=0;$i<$itemCount;$i++) {

    if(!empty($_POST["item_name"][$i]) || !empty($_POST["item_price"][$i]) || !empty($_POST["quantity"][$i])) {


        if($queryValue!="") {

            $queryValue .= ",";


        $queryValue .= "('" . $_POST["item_name"][$i] . "', '" . $_POST["item_price"][$i] . "', '" . $_POST["quantity"][$i] . "')";



$sql = $query.$queryValue;

if($itemValues!=0) {

    $result = mysql_query($sql);

    if(!empty($result)) $message = "Added Successfully.";




<FORM name="frmProduct" method="post" action="">

    <input type="button" name="add_item" value="Add More" onClick="addMore();" />
    <input type="button" name="del_item" value="Delete" onClick="deleteRow();" />

        <input type="submit" id="save" name="save" value="Save" />


<SCRIPT src=""></SCRIPT>
    function addMore() {
        $("").load("input.php", function() {
    function deleteRow() {
        $('DIV.product-item').each(function(index, item){
            jQuery(':checkbox', this).each(function () {
                if ($(this).is(':checked')) {


<DIV class="product-item float-clear" style="clear:both;">
                <input type="checkbox" name="item_index[]" /> 
                <input type="text" name="item_name[]" />
                <input type="text" name="item_price[]" />
                <input type="text" name="quantity[]" />>
Updated 25-Sep-15 2:48am
Andy Lanng 25-Sep-15 7:49am
Please don't shout (use all caps). It is considered rude and you won't get as many views.
Rest assured that all questions get seen and are answered by anyone who considers themselves able to.

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

Please check this article:

Create a CRUD web app using JQuery Mobile & PHP Ajax Calls[^]

This would help you to make ajax call to insert data w/o any page refresh.
Hani Mehdi 25-Sep-15 22:33pm
:$ cant understand

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100