将一些变量从一个php页面移动到另一个页面并在页面之间移动

时间:2017-01-26 09:34:11

标签: javascript php jquery html

我是php新手。我从数据库中获取最后一个id。对于每个id,我想要状态和链接。我将检查是否location.href,然后获取链接的内容(我需要的那个JavaScript变量位于链接内容中)。我将$_GET发送该变量。

然后我在第二页中使用$j获取该变量。我想将var存储到数据库中,然后返回到第一页并从数据库中获取第二个链接并再次执行相同的工作。

如何将x_cor发送到第二页以保存y_cor$j,以及如何在第一页再次增加<html> <head> <title>firstpage</title> </head> <body> <?php include_once ('simple_html_dom.php'); include_once ('split_unicode_function.php'); // getting the last id from db $connection = @mysql_connect("localhost", "root", "kkuser"); $select_db = mysql_select_db("kk", $connection); $sql = "SELECT id FROM netbarg ORDER BY id DESC LIMIT 1"; $result = mysql_query($sql, $connection); $rows = mysql_fetch_array($result); $last_id = $rows['id']; // getting id and link for each column for ($j = 1; $j <= 2; $j++) { $select_db = mysql_select_db("kk", $connection); $id = "SELECT state FROM `table` WHERE id='$j' "; $result = mysql_query($id, $connection); $row = mysql_fetch_array($result); echo $state = $row[0] . '<br />'; // getting link $link = "SELECT link FROM `table` WHERE id='$j' "; $result = mysql_query($link, $connection); $rows = mysql_fetch_array($result); $link = $rows[0]; // (state is just 1 or 2)check if the state is 2 or not... if ($state == 1) { $f = file_get_contents($link); echo "<div>$f</div>"; } } ?> <script> $("body").hide(); location.href ='secondpage.php?val='+point0+; </script> </body> </html> ? / p>

<html>
    <head>
        <title>second page</title>
    </head>
    <body>
    <?php
    if (isset($_GET['val']))
        {
        $hat = $_GET['val'];
        echo $hat;
        $coords = trim($hat, '()');

        // echo $coords.'<br />';

        $a = array();
        $a = explode(",", $coords);
        var_dump($a);
        echo $long = $a[0];
        echo '<br />';
        if ($long == "undefined") $lat = "undefined";
          else echo $lat = $a[1];
        if ($_SERVER['REQUEST_METHOD'] == "GET")
            {
            $connection = @mysql_connect("localhost", "root", "kkuser");
            $select_db = mysql_select_db("kk", $connection);
            $update = "UPDATE `table` SET `x_cor`='$long',`y_cor`='$lat'  ,      `state`='2'  WHERE `id`='$j' ";
            $insert_todb = mysql_query($update, $connection);
            if ($insert_todb) echo "coordinates has been updated", '<br />';
            }
        }

    ?>
    <script>
        location.href ='firstpage.php';
    </script>
   </body>
</html>

第二页

witadmin.exe importwitd /collection:http://servername:port/tfs/collectionName/ /p:ProjectName1 /f:%1
witadmin.exe importwitd /collection:http://servername:port/tfs/collectionName/ /p:ProjectName2 /f:%1
witadmin.exe importwitd /collection:http://servername:port/tfs/collectionName/ /p:ProjectName3 /f:%1
... add more projects here

1 个答案:

答案 0 :(得分:0)

如果获取最后一个插入id,则使用mysqli_insert_id($ con); 它使用您可以

的geted id从数据库返回最后一个插入ID