The newcomer implements the form editing function and asks for help when it encounters a bottleneck.
Edit
The above is the code and only the last row can be modified successfully. The reason is that after I use while to read the Post, I always select the last row. after thinking about it for a while, I cannot figure out how to do it.
For guidance, it is best to have code. JavaScript can understand a little bit, and Jquery won't. after all, php and js haven't fully understood it.
Reply to discussion (solution)
By the way, the previous page does not contain any values and does not have a session.
This page forms are printed directly from the database.
Nobody?
You must post only the last record.
The name attribute of input is the same as that of input.
You must post only the last record.
I understand this. I want to find a solution or code to achieve my goal.
You have different names for each form. Otherwise, you can only get the two POST values $ _ POST ['objname'] and $ _ post ['objinfo '].
You have different names for each form. Otherwise, you can only get the two POST values $ _ POST ['objname'] and $ _ post ['objinfo '].
To:
The name attribute of input is the same as that of input.
I am calling data with id. The problem is that the names of the three columns are the same. how can I separate the values and call them separately?
You have different names for each form. Otherwise, you can only get the two POST values $ _ POST ['objname'] and $ _ post ['objinfo '].
To:
This is a good idea! Try Me
You have different names for each form. Otherwise, you can only get the two POST values $ _ POST ['objname'] and $ _ post ['objinfo '].
To:
How can I use post to extract data?
$ Objname = $ _ POST ["objname"]; how to write
Do you want to save data in different entries? The score group.
In this way, three arrays are obtained. After that, you can directly insert or integrate it into an array and insert it again.
Do you want to save data in different entries? The score group.
In this way, three arrays are obtained. After that, you can directly insert or integrate it into an array and insert it again.
Edit
I changed my mind to this.
Post gets an entire form. I asked him to update and write data one by one, but why didn't I change the database?
The value obtained by post is listed here: array ([id] => Array ([0] => 7 [1] => 8 [2] => 9 [3] => 10) [objname] => Array ([0] => 123123 [1] => 321 [2] => 456 [3] => 654) [objinfo] => Array ([0] => 132132 [1] => 321 [2] => 456 [3] => 654 ))
Do you want to save data in different entries? The score group.
In this way, three arrays are obtained. After that, you can directly insert or integrate it into an array and insert it again.
The idea of this array is good, so that the post value can be distinguished by traversing the array by name: _ POST ['objname [0]. I learned, my idea is to modify the name value through js, which is a bit painful!
Do you want to save data in different entries? The score group.
In this way, three arrays are obtained. After that, you can directly insert or integrate it into an array and insert it again.
Edit
I changed my mind to this.
Post gets an entire form. I asked him to update and write data one by one, but why didn't I change the database?
The value obtained by post is listed here: array ([id] => Array ([0] => 7 [1] => 8 [2] => 9 [3] => 10) [objname] => Array ([0] => 123123 [1] => 321 [2] => 456 [3] => 654) [objinfo] => Array ([0] => 132132 [1] => 321 [2] => 456 [3] => 654 ))
$ _ POST ["objname [I]"]; is there a problem.
Do you want to save data in different entries? The score group.
In this way, three arrays are obtained. After that, you can directly insert or integrate it into an array and insert it again.
Edit
I changed my mind to this.
Post gets an entire form. I asked him to update and write data one by one, but why didn't I change the database?
The value obtained by post is listed here: array ([id] => Array ([0] => 7 [1] => 8 [2] => 9 [3] => 10) [objname] => Array ([0] => 123123 [1] => 321 [2] => 456 [3] => 654) [objinfo] => Array ([0] => 132132 [1] => 321 [2] => 456 [3] => 654 ))
$ _ POST ["objname [I]"]; is there a problem.
If I change it to $ I, I still cannot. Is there any quotation marks?
Do you want to save data in different entries? The score group.
In this way, three arrays are obtained. After that, you can directly insert or integrate it into an array and insert it again.
Edit
I changed my mind to this.
Post gets an entire form. I asked him to update and write data one by one, but why didn't I change the database?
The value obtained by post is listed here: array ([id] => Array ([0] => 7 [1] => 8 [2] => 9 [3] => 10) [objname] => Array ([0] => 123123 [1] => 321 [2] => 456 [3] => 654) [objinfo] => Array ([0] => 132132 [1] => 321 [2] => 456 [3] => 654 ))
$ _ POST ["objname [I]"]; is there a problem.
If I change it to $ I, I still cannot. Is there any quotation marks?
It seems that this is not very good. isn't it possible to get the three arrays from post now? you can combine the three arrays and insert them into the database separately, instead of inserting $ _ POST [[["objname [I]"] into the database, you can insert $ data = array (); $ data = $ _ POST ["objname"], then insert the three newly defined arrays into the database.
If (! Empty ($ _ POST) {while ($ row = mysql_fetch_array ($ result) {$ objname = $ _ POST ["objname []"]; print_r ($ _ POST ["objname []"]); print_r ($ objname); $ objinfo = $ _ POST ["objinfo []"]; $ id = $ _ POST ["id []"]; $ strSql2 = "update table_test set objname = '$ objname ', objinfo = '$ objinfo' where objid =' $ ID' "; $ result2 = mysql_query ($ strSql, $ myconn); if (! $ Result2) {die (mysql_error () ;}} echo "modification successful! ";}
I thought about whether it would be okay without $ I, but I still couldn't get the data in the array in post (it seems to be a basic problem)
You have a hard time
Do you want to save data in different entries? The score group.
In this way, three arrays are obtained. After that, you can directly insert or integrate it into an array and insert it again.
Edit
I changed my mind to this.
Post gets an entire form. I asked him to update and write data one by one, but why didn't I change the database?
The value obtained by post is listed here: array ([id] => Array ([0] => 7 [1] => 8 [2] => 9 [3] => 10) [objname] => Array ([0] => 123123 [1] => 321 [2] => 456 [3] => 654) [objinfo] => Array ([0] => 132132 [1] => 321 [2] => 456 [3] => 654 ))
After searching for half a day, you run $ sqlstr, but the defined string is $ sqlstr2.
Title |
Link |
$ Limit = 5;$ StrSql = "select * from news limit". $ limit;$ Result = mysql_query ($ strSql, $ myconn );While ($ row = mysql_fetch_array ($ result )){$ Title1 = $ row ['title'];$ Link1 = $ row ['link'];?>
|
|
}Print_r ($ _ POST );If (! Empty ($ _ POST )){For ($ I = 0; $ I <$ limit; $ I ++){$ Title = $ _ POST ["title"] [$ I];$ Link = $ _ POST ["link"] [$ I];$ Id = $ _ POST ["id"] [$ I]; $ StrSql = "UPDATE news SET title = '". $ title. "', link = '". $ link. "'Where id = '". $ id. "'";$ Result2 = mysql_query ($ strSql, $ myconn );If (! $ Result2 ){Die (mysql_error ());} Else {// Echo "modified successfully! ";}} }?>
I tested it locally. this is usable. the above is the code in the table.
If (! Empty ($ _ POST) {while ($ row = mysql_fetch_array ($ result) {$ objname = $ _ POST ["objname []"]; print_r ($ _ POST ["objname []"]); print_r ($ objname); $ objinfo = $ _ POST ["objinfo []"]; $ id = $ _ POST ["id []"]; $ strSql2 = "update table_test set objname = '$ objname ', objinfo = '$ objinfo' where objid =' $ ID' "; $ result2 = mysql_query ($ strSql, $ myconn); if (! $ Result2) {die (mysql_error () ;}} echo "modification successful! ";}
I thought about whether it would be okay without $ I, but I still couldn't get the data in the array in post (it seems to be a basic problem)
You have a hard time
I wrote print_r ($ _ POST ["$ objname"]); and print_r ($ _ POST ["$ objname []"]); no response
$ Objname = array ();
$ Bojname = $ _ POST ['bojname'];
$ Objinfo = array ();
$ Bojname = $ _ POST ['bojname'];
$ Id = array ();
$ Id = $ _ POST ['id'];
For ($ I = 0, I $ SQL = 'update table_test set objname = '. $ objname [$ I]. ', objinfo = '. $ objinfo [$ I]. 'Where objid = '. $ id [$ I];
}
Try this idea
Use $ objname = $ _ POST ["objname"] [$ I.
Title |
Link |
$ Limit = 5;$ StrSql = "select * from news limit". $ limit;$ Result = mysql_query ($ strSql, $ myconn );While ($ row = mysql_fetch_array ($ result )){$ Title1 = $ row ['title'];$ Link1 = $ row ['link'];?>
|
|
}Print_r ($ _ POST );If (! Empty ($ _ POST )){For ($ I = 0; $ I <$ limit; $ I ++){$ Title = $ _ POST ["title"] [$ I];$ Link = $ _ POST ["link"] [$ I];$ Id = $ _ POST ["id"] [$ I]; $ StrSql = "UPDATE news SET title = '". $ title. "', link = '". $ link. "'Where id = '". $ id. "'";$ Result2 = mysql_query ($ strSql, $ myconn );If (! $ Result2 ){Die (mysql_error ());} Else {// Echo "modified successfully! ";}} }?>
I tested it locally. this is usable. the above is the code in the table.
It was written in this way. it was taught.
Use $ objname = $ _ POST ["objname"] [$ I.
I didn't think of this at all. if $ _ POST ["objname"] [$ I] gets the post value, it should be able to be inserted. the problem should be solved.
Use $ objname = $ _ POST ["objname"] [$ I.
Thanks for your help. Basically, the problem has been solved. the end value of I in a fixed loop is the form length. let me go here.
Thank you!
Use $ objname = $ _ POST ["objname"] [$ I.
I didn't think of this at all. if $ _ POST ["objname"] [$ I] gets the post value, it should be able to be inserted. the problem should be solved.
More enthusiastic help from this elder brother! So touched
Edit
Here is the final molding code
Thanks to fedcgfedbe and csjazqx for their help!
Use $ objname = $ _ POST ["objname"] [$ I.
Thanks for your help. Basically, the problem has been solved. the end value of I in a fixed loop is the form length. let me go here.
Thank you!
We are not a big guy .. It's not long before you do this. It's just that you can review it yourself when helping others.