"PHP additions and deletions to the example" section 22nd-Introduction Baidu Map

Source: Internet
Author: User

20. User New Address field

In the actual development, there will often be added to the data table or modify the field, so, when the user asked to add a field, our page and the background program will have to make corresponding changes.

This section takes an example of adding an address field.

Open Navicat:



Click on the Save button to add the complete.

Usermanage.html the changes to be made:

Add an Address entry box to the form form for the new page:


A new address field is also added to the table of the user list:

Address

save.php

To modify the SQL statement, add the Addr field:


Add a addr field to the new statement

//新增        $username = $_POST["username"];        $password = md5 ( $_POST["password"] );        $nickname = $_POST["nickname"];        $addr = $_POST["addr"];        $sql = "insert into tm_users values (NULL,‘$username‘,‘$password‘,‘$nickname‘,now(),now(),0,‘$addr‘)";        //用户名非重复检测        $rs = mysql_query("select count(1) as total from tm_users where username = ‘$username‘;");        while($row = mysql_fetch_array($rs)){            if($row["total"] > 0){                $resultData["errCode"] = -1;                $resultData["errMsg"] = "用户名重复!";                echo json_encode($resultData);                return;            }        }        //执行新增操作        mysql_query($sql) or die(err());        echo json_encode($resultData);
Addr Location Preview (Baidu map) 21.1 Change the Address column into a hyperlink

function addrFormatter(val){    if(!val) return "这个用户很懒,没有填写地址。";    return "<a href=\"javascript:map(‘"+val+"‘)\">"+val+"</a>";}function map(addr){}

Because you want to open a map page, now Draw a dialog dialog box with a layer of IFRAME nested inside the dialog box.

 <div id="dialog1" class="easyui-dialog" style="width:800px;height:500px;padding:10px 20px;" closed="true" data-options="title:‘地图‘" >     <iframe id="map" frameborder=0 scrolling=‘auto‘ style=‘width:100%;height:100%‘></iframe>  </div>

When we click here for hyperlinks:

It should pop up dialog1.
Code:

function map(addr){    $("#dialog1").dialog("open");    $("#map").attr("src","http://map.baidu.com/?newmap=1&ie=utf-8&s=s%26wd%3D"+addr);}

Effect:

SOURCE Access: HTTPS://WWW.JIANSHU.COM/P/4977BD0073D5

"PHP additions and deletions to the example" section 22nd-Introduction Baidu Map

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.