更新 3 个图像字段
我遇到了以下问题:
我有一个客户区域,我的客户可以在其中编辑 3 个图像字段。 问题是:
我只想更新数据库中不为空的字段的照片名称。 因此,例如,如果我的客户决定更改照片#2,我需要一个不会覆盖照片#1 和#3 的 mysql 更新。
我可以写很多“if”语句,但我认为有更好的方法来做到这一点。
有什么帮助吗?
I'm running into the following problem:
I've a client area where my client can edit 3 image fields.
The problem is:
I just want to update the photo name in the database for the fields that are not empty.
So, for example, if my client decide to change photo #2, I need a mysql update that will not override photo #1 and #3.
I could write a lot of "if" statements but I think there's a better way to do it.
any help?
也许您可以使用数组和 foreach 语句。它可能是这样的:
Maybe you could use an array and a
foreach
statement. It could be something like: