Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7878441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:39:38+00:00 2026-06-03T03:39:38+00:00

Got a bit of a confusing situation, I have a form on my webpage

  • 0

Got a bit of a confusing situation, I have a form on my webpage that allows a user to enter information into a database…

Form

<form id="insertbill">
     Total <input type="text" id="total" name="total" /><br />
     Bill name<input type="text" id="bill-name" name="bill-name" /><br />
     bill descriptiion <input type="text" id="bill-description" name="bill-description" /><br />
     bill colour<input type="text" id="bill-colour" name="bill-colour" />
     <input type="button" value="submit" onClick="insertBill();" />
</form>  

This form then send the information via AJAX to my php which then inputs it into my DB

AJAX

function insertBill()
{
    $.post('insert_bill.php', $('#insertbill').serialize(), 
        function(data) {
        $('#bills').append(data);
    });
};

PHP

   $uid = $_SESSION['oauth_id'];       
   $bill = mysql_real_escape_string($_POST['total']);
   $billname = mysql_real_escape_string($_POST['bill-name']);
   $billdescription = mysql_real_escape_string($_POST['bill-description']);
   $billcolour  = mysql_real_escape_string($_POST['bill-colour']);

    #Insert Record
    $query = mysql_query("INSERT INTO `outgoings` (user_id, bill, bill_name, bill_description, bill_colour ) VALUES ('$uid', '$bill', '$billname', '$billdescription', '$billcolour')") or die(mysql_error());

Once this is done, the data is then returned to the webpage, with another form that allows the user to update the record…

Returned data/form

Print "<tr>"; 
Print "<th>total:</th> <td>".$bill . "</td> ";
Print "<th>bill name:</th> <td>".$$billname . "</td> ";
Print "<th>bill deposit:</th> <td>".$billdescription . "</td> "; 
Print "<th>colour:</th> <td>". $billcolour . " </td></tr>"; 
echo "<th>edit:</th> <td>

<form id='bill-upd'>
        <input type='hidden' value='". $billname."' name='billid' id='billid''>
        Total <input type='text' id='total' name='total' /><br />
        Bill name<input type='text' id='bill-name' name='bill-name' /><br />
        bill descriptiion <input type='text' id='bill-description' name='bill-description' /><br />
        bill colour<input type='text' id='bill-colour' name='bill-colour' />
        <input type='button' value='submit' onClick='updateBill();' />
    </form>   
</td>"; 

My problem is that the returned form doesn’t update, this is because I need to somehow find the id of the record that was inserted, place it into my form to be returned I think… I hope this isn’t too confusing, but has anybody a better way of doing this without reloading the page?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T03:39:40+00:00Added an answer on June 3, 2026 at 3:39 am

    here’s what what you could include on your, insert_bill.php, view page:

    <script> 
       var json=<? 
           $arr=array($bill, $billname, $billdescription, $billcolour);
           echo json_encode($arr); ?>;
    
         $('tr td:nth-child(0)').html(json[0]);
         $('tr td:nth-child(1)').html(json[1]);
         $('tr td:nth-child(2)').html(json[2]);
         $('tr td:nth-child(3)').html(json[3]);
    
    </script>
    

    I guess the one outstanding issue is the “id” you says gets returned from your database. Can you explain a little further? Are their multiple forms on your insert_bill.php page? Regardless, you could put that $id into the array and feed it into and html() function like I did with the other variables.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a bit of Mac code that needs to store, access and update
I've got the following bit of code to check if a form with multiple
OK, I got bit by something that seems a tad weird. I realize it
I've got a system that takes input from a form, puts it in to
Firstly: apologies if this is a duplicate post. Things got a bit confusing as
I've got a bit of a problem with making my data loading and filtering
I've got this bit of JQUERY: <script> function initNav() { $('.nav tr table td
I've got a bit of an odd issue here. Basically it only occurs in
I've got a bit of a problem. Essentially, I need to store a large
I've got a bit of a complicated set up. I specialise in XSLT which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.