Php form submission updates database table content, only changes the current row

Source: Internet
Author: User
Tags php form
The php form submits and updates the content of the database table. only the content under the attribute field of the current row is changed. I used select to give several values, how to select the value to submit to the database and update the table content in the database, only change the current row


Reply to discussion (solution)

Pass unique identification mark

Submit and modify the content of the current row of the database

Update a database based on the submitted id,

Pass unique identification mark



How can I obtain the unique identifier? Js is not very good. can you write a simple example?

Submit and modify the content of the current row of the database

Update a database based on the submitted id,



I know that, but how can I get that id?

The only identification mark you gave me!
Assume that the QQ number is unique in the data in your example.

The only identification mark you gave me!
Assume that the QQ number is unique in the data in your example.



I know what the unique identifier means. I mean, how do I get the value? is it JavaScript? Or can the form be obtained?

You can use checkbox to pass values in the form.

You can use checkbox to pass values in the form.



Can I write logic or write several lines of code? I'm a really good rookie. you only say that I am not very useful.

It is to add a field similar to id in the database structure, which should be an automatically generated id value, that is, each time you create a data record, a unique id value will be generated, then use this id to pass the value. for example, when updating, the condition must be where id = 1 or a few

Then, in the operation interface, you need to provide an id or name value for your operation, which is a unique identifier, in this case, your js code should also have an id or name value that is the same as it. the method written by js is to call or operate the database.

It is to add a field similar to id in the database structure, which should be an automatically generated id value, that is, each time you create a data record, a unique id value will be generated, then use this id to pass the value. for example, when updating, the condition must be where id = 1 or a few



I know I want to do this, but I won't pass it or get it... I can write a function description for my reference.

#11

update table_name set IP=11.11.11.11 where qq=1234567;

#11

update table_name set IP=11.11.11.11 where qq=1234567;



I know how to obtain the QQ from that line, because it is random and not fixed.

 

Call the method name = a or id = a in the above js.
function a(){}


#11

update table_name set IP=11.11.11.11 where qq=1234567;



I know how to obtain the QQ from that line, because it is random and not fixed.


So what is fixed in your database table? Which field do you want to change?



#11

update table_name set IP=11.11.11.11 where qq=1234567;



I know how to obtain the QQ from that line, because it is random and not fixed.


So what is fixed in your database table? Which field do you want to change?



The field of the property is changed. the QQ number is filtered out by other conditions. because the QQ number is a unique primary key, you can obtain the row where the QQ number is located and enter the attribute content in the form, update data table


The content under this attribute field, I used select to give a few values, how to select the value to submit to the database and update the table content in the database, only change the current row


Also, should you use insert to add values? How do you use select for interpolation? It is a query, not an increase or a change.





#11

update table_name set IP=11.11.11.11 where qq=1234567;



I know how to obtain the QQ from that line, because it is random and not fixed.


So what is fixed in your database table? Which field do you want to change?



The field of the property is changed. the QQ number is filtered out by other conditions. because the QQ number is a unique primary key, you can obtain the row where the QQ number is located and enter the attribute content in the form, update data table


Are there other tables for the QQ number? Have you found this table or have it been saved?

You can find out this. when it is displayed, upload the id and save it with an input type = "hidden,
After select is selected, after submitting the form, take out the value of $ _ REQUEST in php, and then update



The content under this attribute field, I used select to give a few values, how to select the value to submit to the database and update the table content in the database, only change the current row


Also, should you use insert to add values? How do you use select for interpolation? It is a query, not an increase or a change.



Select is not used in the database. The database uses insert into newdata ('properties') values ($ _ POST ['name']). #11 Update table_name set IP = 11.11.11.11 where qq = 1234567; I know how to obtain the QQ from that line, because it is random and not fixed. So what is fixed in your database table? Which field do you want to change? The field of the property is changed. the QQ number is filtered out by other conditions. because the QQ number is a unique primary key, you can obtain the row where the QQ number is located and enter the attribute content in the form, update data table Are there other tables for the QQ number? Have you found this table or have it been saved? This is the row to be modified after other operations are found.
I also posted the code. please help me modify it.

"Insert into 'newdata' ('properties') VALUES ('$ _ POST [s]') where ????? "
Why insert

"Insert into 'newdata' ('properties') VALUES ('$ _ POST [s]') where ????? "
Why insert




Changed. the update 'newdata' set 'attribute is' $ _ POST [s] '.

After the modification, you still need to change the location, that is, you did not write the table label, but directly wrote the tr and td, just did not add the table label, I did not get the QQ number with js and jQuery, therefore, you must use the table label to enclose tr and td, and then obtain the QQ number. you can use js to obtain the QQ number or introduce jQuery to obtain it.
If it is js, then

var qq = document.getElementById('t1');var qq_num = qq.innerHTML;//alert(qq_num);

If jQuery is used (don't forget to introduce jQuery ),
var qq_num = $('td:eq(0)').html();




Add an id to this td tag to document. getElementById ('T1 ')

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.