这是用建议更新的整个代码。还添加了新的列名。让我知道它是否正确。
<?php
//Initialize your first couple variables
$encodedString = ""; //This is the string that will hold all your location data
$x = 0; //This is a trigger to keep the string tidy
//Now we query to the database
$result = mysql_query("SELECT visitors_pb_list.first, visitors_pb_list.last, visitors_pb_list.ip, visitors_pb_list.landing_page as visitors_pb_list_landing_page, pb_list.address, pb_list.landing_page as pb_list_landing_page, ziplatlang.longitude, ziplatlang.latitude FROM visitors_pb_list LEFT JOIN pb_list ON visitors_pb_list.landing_page = pb_list.landing_page LEFT JOIN ziplatlang ON pb_list.zip = ziplatlang.zip_code WHERE landing_page='" . $pb_list_id . "' order by id desc");
//Multiple rows are returned
while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
//This is to keep an empty first or last line from forming, when the string is split
if ( $x == 0 )
{
$separator = "";
}
else
{
//Each row in the database is separated in the string by four *'s
$separator = "****";
}
//Saving to the String, each variable is separated by three &'s
$encodedString = $encodedString.$separator.
"<p class='content'><b>Lat:</b> ".$row['latitude'].
"<br><b>Long:</b> ".$row['longitude'].
"<br><b>Name: </b>".$row['first'].$row['last'].
"<br><b>Address: </b>".$row['address'].
"<br><b>IP: </b>".$row['ip'].
"</p>&&&".$row['latitude']."&&&".$row['longitude'];
$x = $x + 1;
}
?>
<input type="hidden" id="encodedString" name="encodedString" value="<?php echo $encodedString; ?>" />
如果你想知道我在哪里得到基本代码,它在这里:
但是我正在尝试使其适应多个表。不能只用一个。需要使用visitors_pb_list
for循环。需要ziplatlang
用于纬度和经度。需要使用通过列pb_list
来桥接另外两个表。zip
到目前为止还没有找到成功。