用PHP更新mysql中的多行(Updating multiple rows in mysql with PHP)
我有folliwing PHP文件
这是创建此表格:
表格由PHP和MySQL数据创建
每行有两个输入。 我的数据库表有AUTO_INCREMENT'ID'字段。
我怎样才能更新我的数据库表,并确保行将相应地更新到ID(自动递增字段)?
我必须承认,使用PHP的SQL对我来说是非常新的,我不知道这样做是否正确?
$news_SQLupdate = "UPDATE news SET "; // table name is 'news' $news_SQLupdate .= "LIVE= '".$LIVE."', "; $news_SQLupdate .= "CONTENT= '".$CONTENT."', "; $news_SQLupdate .= "WHERE ID = '".$ID."' ";I have folliwing PHP file
which is creating this table:
Table createb by PHP with MySQL data
Every row have two inputs. My DB table has AUTO_INCREMENT 'ID' field.
How can I update my DB Table and make sure that rows will be updated accordingly to the ID's (auto incremented field)?
I'm must admit that SQL with PHP is very new to me and I don't know is this correct way of doing it?
$news_SQLupdate = "UPDATE news SET "; // table name is 'news' $news_SQLupdate .= "LIVE= '".$LIVE."', "; $news_SQLupdate .= "CONTENT= '".$CONTENT."', "; $news_SQLupdate .= "WHERE ID = '".$ID."' ";最满意答案
通过在WHERE子句中包含该id?
UPDATE <someTable> SET ... WHERE id = <someId>By including the id in the WHERE clause?
UPDATE <someTable> SET ... WHERE id = <someId>更多推荐
发布评论