数组的值更改为 sql 或数组直接更改为每个索引列中的 sql =>结果
好吧,我找到了如何打印我的全局数组,效果很好,但现在我有一个问题,我想将该数组打印到 sql 中,
代码:
print_r($_SESSION['cart']);
返回:
Array ( [1] => 2 [2] => 1 [3] => 1 )
那太好了,我确切地知道选择了什么,但用户不知道...
所以我的问题是我如何在sql数据库中打印该数组,但更改索引
示例:
Array ( [1] => 2 [2] => 1 [3] => 1 )
for
Array ( [name1] => 2 [name2] => 1 [name3] => 1 )
仅当索引[x]存在于当前数组结果中时才基于
[name1] => 2
[name2] => 1
[name3] => 1
,因此在数据库中将看起来像这样:我可以只需回拨该线路即可,或者如何在不同列上打印同一个数组
示例:
from array : Array ( [1] => 2 [2] => 1 [3] => 1 )
to sql :
id quantity
[1] 2
[2] 1
[3] 1
是否可以以这种方式在 sql 中打印数组?以及如何
提前做到这一点
Well i found out how to print my global arrays, works great but now i have a problem, i want to print that array into sql
the code :
print_r($_SESSION['cart']);
returns :
Array ( [1] => 2 [2] => 1 [3] => 1 )
thats great, i know exactly what has been select, but the user wont know that...
so my question its how can i print that array in sql database but changing the index
example :
Array ( [1] => 2 [2] => 1 [3] => 1 )
for
Array ( [name1] => 2 [name2] => 1 [name3] => 1 )
based only if the index [x] exist in the current array results so in the database will look somehting like this :
[name1] => 2
[name2] => 1
[name3] => 1
and i can just call that line back, or how to print on diferent columns the same array
example :
from array : Array ( [1] => 2 [2] => 1 [3] => 1 )
to sql :
id quantity
[1] 2
[2] 1
[3] 1
is it posible to print the array in sql in this way ? and how to do that
Ty in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以从 sql 获取数据:
您可以这样打印:
...我想更改名称的索引。 很简单:
保存代码
You can get data from sql:
You can print this way:
...and i want to change the index for the name. It's easy
code for saving: