小编cop*_*910的帖子

科尔多瓦的HTML5 localstorage

HTML5本地存储在Cordova/PhoneGap中有效吗?我试图使用它,HTML5方式和文档中指定的方式.都没有工作.

具体来说,我试图使用ajax查询结果进行本地存储.我测试了查询,它的工作原理.

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="format-detection" content="telephone=no">
    <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi">
    <title>Hello World</title>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js" type="text/javascript">

    </script>
    <script type="text/javascript">
        $(document).ready(function () {
            $("form").submit(function () {

                var uname = document.getElementById("username").value;
                var pword = document.getElementById("password").value;
                var postData = {
                    username: uname,
                    password: pword
                };

                $.ajax({
                    url: "http://www.yellowcabsavannah.com/test.php",
                    type: "POST",
                    data: postData,
                    async: false,
                    dataType: 'json',
                    cache: false,
                    success: function (data) {
                        localStorage.uname = data.username;
                        localStorage.pword = data.password;
                        alert(localStorage.uname);
                    }
                }
                });
            return false;
            }); …
Run Code Online (Sandbox Code Playgroud)

html5 local-storage cordova

17
推荐指数
2
解决办法
2万
查看次数

如何使用php添加到.json文件中的json数组

如何用php添加到.json文件?目前,我正在使用php附加.json文件,但它不会将数据添加到现有的json对象.它创造了一个新的对象.我需要将所有数据存储在一个对象中,在外部JSON文件中.基本上,我有一个json对象,并希望为它添加更多的值.

谢谢

现行守则

<?php

$username = mysql_real_escape_string($_POST['username']);
$password =  mysql_real_escape_string($_POST['password']);

$sql="SELECT * FROM accounts WHERE uname = '$username' AND pword = '$password'";

$r = mysql_query($sql);

$name = "";

while($row = mysql_fetch_array($r))
{
    $name = $row["name"];
    $lat = $row["lat"];
    $lon = $row["lon"];
    $it = $row["it"];
}

if(mysql_num_rows($r) != 1){
    echo json_encode(array("message" => "Nope! Wrong Login!"));
}
if(mysql_num_rows($r) == 1)
{

    $jsonFile = "test.json";
    $fh = fopen($jsonFile, 'w');

    $json = json_encode(array("message" => $name, "latitude" => $lat, "longitude" => $lon, "it" => $it)); …
Run Code Online (Sandbox Code Playgroud)

php arrays json file

1
推荐指数
1
解决办法
2万
查看次数

使用MySQL的Haversine Fomula到达附近的位置

我正在尝试在PHP/MySQL中使用hasrsine公式将附近的位置移到我所在的位置

我正在使用AJAX在我的谷歌地图上只获取附近的标记.

我所知道的是我的查询没有返回任何内容.

我知道在我看的地方有一个位置.

基本上,使用hasrsine公式我的代码出了什么问题?

编辑 - 从这里改变吨以遵循教程.错误仍然是一样的.

PHP

$lati = 40.78405877579076;
$longi = -73.94800172194275;

class RadiusCheck
{
    var $maxLat;
    var $minLat;
    var $maxLong;
    var $minLong;

    function RadiusCheck($Latitude, $Longitude, $Miles)
    {
        global $maxLat,$minLat,$maxLong,$minLong;
        $EQUATOR_LAT_MILE = 69.172;
        $maxLat = $Latitude + $Miles / $EQUATOR_LAT_MILE;
        $minLat = $Latitude - ($maxLat - $Latitude);
        $maxLong = $Longitude + $Miles / (cos($minLat * M_PI / 180) * $EQUATOR_LAT_MILE);
        $minLong = $Longitude - ($maxLong - $Longitude);
    }

    function MaxLatitude()
    {
        return $GLOBALS["maxLat"];
    }
    function …
Run Code Online (Sandbox Code Playgroud)

php mysql location distance google-maps-markers

-3
推荐指数
1
解决办法
574
查看次数