经销商信息存储在MySQL数据库中,其中包含以下列:Name, CompanyName, ContactName, emai, password, liststate, listcountry
等。
liststate =州 listcountry = Contry
我试图用html选择表单获取经销商数据但由于某种原因它没有显示任何内容。我也找不到任何php错误日志。我有什么遗漏或需要任何改进
<?php
function varscan($str) {
return ($str != NULL)?ereg_replace('[^0-12]', "", $str):'0';
}
function varscanchar($str) {
return stripslashes(str_replace(array('+','=','-','*',',',"'",'"','<','>'),array('+','=','-','*',',',''','"','<','>'),$str));
}
$liststate = varscanchar($_GET['liststate']);
//$liststate = $_GET['liststate'];
$listcountry = varscanchar($_GET['listcountry']);
//$listcountry = $_GET['listcountry'];
if($liststate || $listcountry)
{
echo "<center><h1>Dealers in $liststate</h1></center>";
$db = mysql_connect("localhost", "databaseuser", "dbuserpassword");
mysql_select_db("databasename");
if($listcountry=="" || $listcountry=="Country") { $listcountry="none"; }
else
{
$sql = "SELECT * FROM dist WHERE (liststate='".$listcountry."') ORDER BY `city`";
}
if($liststate==""|| $liststate=="State/Province") { $liststate="none"; }
else
{
$sql = "SELECT * FROM dist WHERE (state='".$liststate."') ORDER BY `city`";
}
//echo $sql;
$result = mysql_query($sql);
echo "<form method=\"post\" action=\"$PHP_SELF\">";
echo '<table border=1 align="center">';
$sw=true;
if($result){
while ($myrow = mysql_fetch_assoc($result))
{
if($myrow['map']=="y" || $myrow['map']=="Y")
{
if($sw==true)
{
echo '<tr bgcolor="#99CCFF">';
echo '<td><b><font size="2">Company</font></b></td>';
echo '<td><b><font size="2">Address</font></b></td>';
echo '<td><b><font size="2">City</font></b></td>';
echo '<td><b><font size="2">State</font></b></td>';
echo '<td><b><font size="2">Zip</font></b></td>';
echo '<td><b><font size="2">Phone</font></b></td>';
echo '<td><b><font size="2">Website</font></b></td>';
echo '<td><b><font size="2">Email</font></b></td>';
echo '</tr>';
$sw=false;
}
echo "<tr>
<td><font size=\"2\">$myrow[company]</font></td>
<td><font size=\"2\">$myrow[address]</font></td>
<td><font size=\"2\">$myrow[city]</font></td>
<td><font size=\"2\">$myrow[state]</font></td>
<td><font size=\"2\">$myrow[zip]</font></td>
<td><font size=\"2\">$myrow[phone]</font></td>
<td>".((empty($myrow['website']) || ($myrow['website'] == 'none'))?'':"<a href=\"http://$myrow[website]\" target\"_blank\"><font size=\"2\">Visit our site</font></a>")."</td>
<td><a href=\"mailto: $myrow[email]\"><font size=\"2\">Email us</font></a></td>
</tr>";
$count=true;
}
}
}
}
?>