dpli36193 2011-03-31 14:39
浏览 237
已采纳

将多维数组值存储到MySQL(PHP)中

I have a large multidimensional array that I would like to store into a MySQL database.

Below is an example of the array in question:

Array
(
    [user1] =>
        [name] => abc
        ...
        [address] => xyz
    ...
    ...
    [user2] =>
        [name] => abc
        ...
        [address] => xyz
}

The array values and database table columns all match (apart from the rowid in the database). I have seen various methods of doing something similar, but haven't found a way that works in this solution.

Many thanks :)

Update

Updated the array structure to give a clearer idea whats in the array itself.

  • 写回答

6条回答 默认 最新

  • dtup3446 2011-03-31 15:27
    关注

    In the end I took the time to use a for loop and achieve the following:

    for ($i = 0; $i < 25; $i++)
        {
            $name = $parts[$i][0];
            $address = $parts[$i][22];
    
            // Run SQL query using the variable values rather than the array values.
        }
    

    I'm sure there is a more sophisticated way of achieving this, but this worked for now!

    Thanks all.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(5条)

报告相同问题?

悬赏问题

  • ¥15 lammps Gpu加速出错
  • ¥15 关于PLUS模型中kapaa值的问题
  • ¥15 关于博途V17进行仿真时无法建立连接问题
  • ¥15 请问下这个红框里面是什么文档或者记事本编辑器
  • ¥15 机器学习教材中的例题询问
  • ¥15 求.net core 几款免费的pdf编辑器
  • ¥15 为什么安装HCL 和virtualbox之后没有找到VirtualBoxHost-OnlyNetWork?
  • ¥15 C# P/Invoke的效率问题
  • ¥20 thinkphp适配人大金仓问题
  • ¥20 Oracle替换.dbf文件后无法连接,如何解决?(相关搜索:数据库|死循环)