Jump to content

One submit button for multiple pieces of data


gitn32

Recommended Posts

You didn't apply the previously mentioned fixes. This:

<td><form action=bills.php method=POST<input type=submit name=submit value=Remove</form></td>

should be something like this:

<td><form action=\"bills.php\" method=\"POST\"> <input type=\"submit\" name=\"submit\" value=\"Remove\"><input type=\"hidden\" name=\"id\" value=\"$id\"></form></td>
Link to comment
Share on other sites

<form action=bills.php method=POST<input type=submit name=submit value=Remove</form>

Valid HTML would be helpful here.

 

I pointed that out in replies 18 and 19 on this thread. If OP doesn't fix it this go around I think I'm done with this topic.

 

Apologies for the snarky tone.

Edited by davidannis
Link to comment
Share on other sites

How do I know that id is an integer? Probably is but I don't think that you can tell from the code. If it is an integer and is never going to change to a string then you are right making it an int will be faster.

 

can't remember ever seeing an id that wasn't an integer

Link to comment
Share on other sites

  • 2 weeks later...

If fixed this on my real code. Let me re-explain the problem. I have 2 pieces of data. They are both displayed on the webpage. They each have the own account balance. For example, 1 can be 500, and the other can be 750. Lets say 500 is on the top of the page. I click the remove button, and 750 (which is on the bottom of the page) is subtracted from the account balance. I would like to make it where, when I click the top amount (500), that 500 is subtracted from the account balance, instead of 750. Your guys are telling me what's wrong with my HTML, which I have fixed. I appreciate that, but it's not the question. Please trty and help with the one above, if you can't help then that's fine. I appreciate your guys' time.

Link to comment
Share on other sites

if you understood the method of passing the id of each piece of data as a hidden field in the delete logic, what exact problem are you having applying that method to the update logic?

 

just posting your update logic (repeatedly) and asking what to do for it, when you just went through the process of making your delete logic work, isn't going to get you much sympathy or help on a forum.

Link to comment
Share on other sites

  • 2 weeks later...

And you are logged in as a user. So I guess the problem is my query:

 

mysql_query("UPDATE users SET accbal = '$newaccbal' WHERE id = $_POST['id'] AND username = '$user'");

 

This is what I have, and I'm using the hidden input, but it comes up with a error.

Link to comment
Share on other sites

if you look at the code you ended up with for the delete process, i'm willing to bet that's not how you got the id value into the query statement.

 

you just successfully passed an id value through a form and into the query for your delete process, other than the query changing to an UPDATE query and there being an amount involved, the method and your code should be nearly identical.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.