dthswrp84966 2016-03-18 01:46
浏览 66
已采纳

获取数组详细信息PHP

I have a google map on this page, all markers were generated by submit postcodes. So I have the array below, loop info of each marker, imploded as ("array", "array") format, I am trying to click on a infoWindow and display the according marker details on details.php. The problem is everything is on the button onclick event, only a simple get on the second page.

This is working, but it is a very bad way. Because the limit to URL length and security reasons; I would like to be able to get an array info from details.php page, and the button onclick event trigger url looks like: details.php?marker=id

I don't know what is the best way to go about this, can someone pointing me to the right direction please?

index.php

       $info = array();

       foreach($stmt as $x)
        {
          $info[] =            
            "<h4>" . $x['name'] . "</h4><hr />".
            "<h5>Address: </h5>" . $x['Address']."<br />" . 
            "<h5>Postcode: " . $x['postcode'] ."</h5><br />" . 

            "<button onclick='window.location.href= \\\"details.php?marker=". "<h4>" . $x['name'] . "</h4><hr />".
            "<h5>Address: </h5>" . $x['address']."<br />" . "<h5>Postcode: " . $x['postcode'] ."</h5><br />" .  "\\\" ' >
            View Details</button>"; 
        }           
        $i=' "'.implode('","', $info).'"';

details.php

echo $infomarker = $_GET['marker']; 
  • 写回答

3条回答 默认 最新

  • dongmu2174 2016-03-18 04:55
    关注

    You have to use $x['id'] insted of $x['name'] which is unique in your database and also use base64_encode() for encryption of your id "details.php?marker=".base64_encode($x['id'])."

    In your details.php

    $infomarker = base64_decode($_GET['marker']);

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

报告相同问题?

悬赏问题

  • ¥15 vs2022无法联网
  • ¥15 TCP的客户端和服务器的互联
  • ¥15 VB.NET操作免驱摄像头
  • ¥15 笔记本上移动热点开关状态查询
  • ¥85 类鸟群Boids——仿真鸟群避障的相关问题
  • ¥15 CFEDEM自带算例错误,如何解决?
  • ¥15 有没有会使用flac3d软件的家人
  • ¥20 360摄像头无法解绑使用,请教解绑当前账号绑定问题,
  • ¥15 docker实践项目
  • ¥15 利用pthon计算薄膜结构的光导纳