用PHP更新mysql中的多行(Updating multiple rows in mysql with PHP)

编程入门 行业动态 更新时间:2024-10-17 04:51:21
用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>

更多推荐

本文发布于:2023-07-17 13:07:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1144919.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:mysql   PHP   Updating   rows   multiple

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!