将JsonArray键值数据插入mysql数据库

时间:2016-07-24 20:49:01

标签: php mysql json

我正在尝试将jsonarray数据插入到mysql数据库中。我正在使用Android应用程序将jsonarray发送到服务器到PHP脚本。 以下是我为PHP方编写的代码:

$jsonArray = $_REQUEST['data'];

$Array = json_decode($jsonArray);

foreach($Array as $row){

    foreach($row as $name => $phone){

        echo $name.':'.$phone;

        $sql = "INSERT INTO contact (Name, Phone_numbers) VALUES ('$name', '$phone')";
        $result_set = mysql_query($sql);
    }
}

正确保存$name,但无法正确保存$phone(数字)。

请有人帮助我。

感谢

1 个答案:

答案 0 :(得分:0)

如果您尝试再采取解决方案

Sub change_orrtime_4()    
    Dim employee As Range
    Dim datefield As Range
    Dim tRows As Long
    Dim tCols As Long
    Dim i As Long


    With Sheets("Timesheet Data")
        With .ListObjects("Timesheet_RawData")
            With .DataBodyRange
                tRows = .Rows.Count
            '    tCols = .Colummns.Count
            End With
            Set employee = .ListColumns("Employee").DataBodyRange
            Set datefield = .ListColumns("Date").DataBodyRange
        End With

        For i = 1 To tRows
            If employee(i).Value = "Some Name" And datefield(i).Value = "1" Then employee(i).Value = "Some Name_SomeTeam"
        Next i        
    End With        
End Sub