I have a table that have 150 column.Now I want to update my row.
Suppose when I select my update form select box item type football.
Now in form I fill data.
No, I don't know the column name.But Know which number of column use.
Now how can I update without column name ?
For what I know you need to use the column name in SQL.
Here is a solution that might help you to solve your problem Is it possible to SQL Update using row and column numbers?
Create an array that maps column numbers to names:
$cols = array('id', 'name', 'sport', ...);
Then when you're updating the row, you can do:
$col_name = $cols[$col_number];
$sql = "UPDATE yourTable SET `$col_name` = :value";
$stmt = $conn->prepare($sql);
$stmt->bindValue(':value', $col_value);
$stmt->execute();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.