I am a new PHP user.
Pulling data from MYSQL as shown in the figure
The table is displayed.
Erase button in foreach minutes,
I wanted to delete only the ID in the same line, I tried variously,
When you press the delete button, all IDs disappear, or the data disappears line by line when loading a page.
Was this idea wrong in the first place?
I would be pleased if someone could tell me the solution.
The code is as follows.
$pdo is a variable that is defined when displaying the table.
The table name is test_php,
php is version 5.4.16.
Answer # 1
When the screen is displayed, PHP is running (check the html in the browser's "view source").
If you want to delete only the data selected (clicked) from the list, it is common to pass the key such as id to PHP with Ajax and execute the deletion process in the background.
If it is difficult, you can attach the same name to the button, add each id to value, and submit form.
And in the current creation, $result is a value that has left foreach, so only the last data is kept
The last data is deleted when the screen is displayed without pressing the delete button.
Since it is a deletion process after the screen display process, it does not affect the display.
It has been deleted on the database.
- php foreach statement loop processing
- i think it's better to use an if statement (php)
- php - i don't want to use foreach! !! !!
- i want to delete all db table data from php
- i want to make a batch process of php with a worker of heroku
- php - i want to prevent the if statement from responding if it is null
- php - connection to mysql, grant statement, root privileges
- php i want to add a deletion function to delete only a specific number on the simple bulletin board
- i want to register with the insert statement of php
- how to use if statement in php
- php - delete function does not work well
- how to ajax receive the variable to be acquired in php for statement at the time of button click and pass it to the php script
- java - i want to implement a process to delete the contents selected with a radio button from the list
- php: i want to keep repeating the process of randomly getting from the array until the button is pressed
- combination of php for statement and conditional expression
- whether to put the sql statement directly or as a variable in the argument of prepare when issuing the sql statement of php
- php - cannot process comit method as undefined method
- how to intentionally create a zombie process in php
- php - i want to save the file path in mysql
- Doesn't output ANGULAR PHP MVC data
- Sort php array by value
- php : joining 2 MySQL tables and outputting data to a table
- php : Yii2 Problem .SQLSTATE [HY000]: General error: 1364 Field 'n_category_id' doesn't have a default value
- php : Redirecting from the page if the user data in the database does not match
- How can you display the latest articles (last 24 hours) in php? [closed]
- About PHP multi-condition search
- php : How to list categories along with subcategories and posts in WP?
- php : How to display information from a table in a loop (RedBean)