How can I delete the corresponding records in the database when I click a record in the table on the php webpage?

Source: Internet
Author: User
Tags form post
How can I delete the corresponding records in the database when I click a record in the table on the php webpage? For example, the table in a webpage written in php is similar:

SN name gender deletion Edit
1. Sanman deletion and editing
2. delete and edit the female Li

The sequence number, name, and gender are read directly from the database.

How to delete the entire record with serial number 1 from the database when you click "delete" with serial number 1?
(The deletion is in href format and is linked to the processing page .)

To obtain the sequence number by clicking "delete", and then pass it to the processing page through form POST,
Operate databases on the processing page.
But I don't know how to obtain the serial number ~~~~~~~~~~
Thank you!


Reply to discussion (solution)

You must use js to obtain the serial number and assign it to a field in the form for post operations.
If you delete a file, you can use Ajax to perform this operation. This prevents the entire page from being refreshed when the form is submitted.

You must use js to obtain the serial number and assign it to a field in the form for post operations.
If you delete a file, you can use Ajax to perform this operation. This prevents the entire page from being refreshed when the form is submitted.



It is not just deletion, but also "editing". It is also page jump and processing in the new page.
How can I implement this js serial number acquisition? there is also a field assigned to the form ......
I tried a lot ......
For example, if the following row is not found
Delete

Row not found?
SN name gender deletion Edit
1. Sanman deletion and editing
2. delete and edit the female Li

So? Some ?? How are you? Outgoing ?? Outgoing generation ??? Look

Row not found?
SN name gender deletion Edit
1. Sanman deletion and editing
2. delete and edit the female Li

So? Some ?? How are you? Outgoing ?? Outgoing generation ??? Look


Through $ sqklink,
$ SQL = "select * from users ",
$ Mysql_query () to read ~~~~

The key is that this row does not seem to recognize it...

Http://blog.csdn.net/MoreWindows/article/details/7102362
For reference in this article, we can obtain the Id serial number through the processing page,

But I still don't know how to get this id ....


You must use js to obtain the serial number and assign it to a field in the form for post operations.
If you delete a file, you can use Ajax to perform this operation. This prevents the entire page from being refreshed when the form is submitted.



It is not just deletion, but also "editing". It is also page jump and processing in the new page.
How can I implement this js serial number acquisition? there is also a field assigned to the form ......
I tried a lot ......
For example, if the following row is not found
Delete


Is your program written together with php and html. When you loop through the array, you can use the array subscript as the serial number and then delete it as you would write.
Delete the row. If an error is reported, paste it completely

 


Replace the database field with the serial number name and gender.

? ? Example.

 
 
 
Order? Name Sex? ? Division ??
">? Division "> ??



You must use js to obtain the serial number and assign it to a field in the form for post operations.
If you delete a file, you can use Ajax to perform this operation. This prevents the entire page from being refreshed when the form is submitted.



It is not just deletion, but also "editing". It is also page jump and processing in the new page.
How can I implement this js serial number acquisition? there is also a field assigned to the form ......
I tried a lot ......
For example, if the following row is not found
Delete


Is your program written together with php and html. When you loop through the array, you can use the array subscript as the serial number and then delete it as you would write.
Delete the row. If an error is reported, paste it completely



Thank you, enthusiastic.
(Forgive me for not posting code directly, because programming machines cannot connect to the internet ...... I can only describe it as much as possible. thank you for your patience)
It is written by mixing php and html.
There are currently two webpages: users. php and delete. php.
In this example, user. php uses table to display the information of each user, including the serial number and name. each user record is deleted ". The implementation is as follows:
 

In this way, the delete. php file after href is submitted through POST, right?
We plan to use this id to retrieve the corresponding records in the database through delete. php, and then delete the records:
$sql="delete * from users where id =' ". $_POST['id']. " ' ";

However, the error message is: POST ['id'] cannot recognize this id, indicating that the search name is invalid.
I don't know what went wrong ~~ ·

Although you have a form outside. But either post or URL is submitted (submitted through the address bar ).
$ SQL = "delete * from users where id = '". $ _ POST ['id']. "'"; it should be written like this
$ SQL = "delete * from users where id = '". $ _ GET ['id']. "'";

However, the error message is: POST ['id'] cannot recognize this id, indicating that the search name is invalid. Is this statement reported in delete. php?
If your user. php page is not well written, refer to

However, the error message is: POST ['id'] cannot recognize this id, indicating that the search name is invalid. Is this statement reported in delete. php?
If your user. php page is not well written, refer to


Yes, an error occurred in delete. php.
Tip: Undefined index id in delete. php on line 4

Let me try your suggestions first. thank you ~~~

"> Delete

1. remove unnecessary spaces and quotation marks from the url.
2. use $ _ GET ['id'] instead of $ _ POST ['id'].
3. if you really want to use the post method. You can use ajax

 


Replace the database field with the serial number name and gender.




? ? Example.

 





Although you have a form outside. But either post or URL is submitted (submitted through the address bar ).
$ SQL = "delete * from users where id = '". $ _ POST ['id']. "'"; it should be written like this
$ SQL = "delete * from users where id = '". $ _ GET ['id']. "'";





"> Delete

1. remove unnecessary spaces and quotation marks from the url.
2. use $ _ GET ['id'] instead of $ _ POST ['id'].
3. if you really want to use the post method. You can use ajax



Thank you for your patience. with your help, the problem has been solved. thank you very much. O (Partition _ partition) o
Among them, the, floor has the largest reference value
"> Delete

This code is correct. to obtain the id of the current row, the key is to use $ _ GET ['id'] in the processing page, and the id I is in lower case,
I mixed this id with the database field Id, so it was written as $ _ GET ['id'], resulting in a constant error.
I hope to help people who have the same troubles.
Thank you again for your patience.

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.