Hello,
I am looking to make an image (prc-header.png) to not show in the else statement. Can anyone point me in the right direction to accomplish this.
Here is a snippet of the code:
[php]print "

[/php]
Here is the full php page code image is located after the //Get PRCs line:
[php]
<?php
$dbcon = mysql_connect("localhost", "standup_ipuser", "T942mwxFna%G") or die(mysql_error());
mysql_select_db("standup_ip2location", $dbcon);
$ip = $_SERVER['REMOTE_ADDR'];
//$ip = '96.253.7.71';
function is_bot(){
$botlist = array("Teoma", "alexa", "froogle", "Gigabot", "inktomi",
"looksmart", "URL_Spider_SQL", "Firefly", "NationalDirectory",
"Ask Jeeves", "TECNOSEEK", "InfoSeek", "WebFindBot", "girafabot",
"crawler", "www.galaxy.com", "Googlebot", "Scooter", "Slurp",
"msnbot", "appie", "FAST", "WebBug", "Spade", "ZyBorg", "rabaz",
"Baiduspider", "Feedfetcher-Google", "TechnoratiSnoop", "Rankivabot",
"Mediapartners-Google", "Sogou web spider", "WebAlta Crawler", "TweetmemeBot", "Butterfly", "Twitturls", "Me.dium", "Twiceler");
foreach($botlist as $bot){
if(strpos($_SERVER['HTTP_USER_AGENT'],$bot)!==false)
return true; // Is a bot
}
return false; // Not a bot
}
if (is_bot()) {
echo "Hey, you're a bot! What's up?";
}else {
//Start Web Service Code
$query = "http://geoip.maxmind.com/f?l=AFRi0OUowosv&i=" . $ip;
$url = parse_url($query);
$host = $url["host"];
$path = $url["path"] . "?" . $url["query"];
$timeout = 1;
$fp = fsockopen ($host, 80, $errno, $errstr, $timeout)
or die('Can not open connection to server.');
if ($fp) {
fputs ($fp, "GET $path HTTP/1.0
Host: " . $host . "
");
while (!feof($fp)) {
$buf .= fgets($fp, 128);
}
$lines = explode("
", $buf);
$data = $lines[count($lines)-1];
fclose($fp);
} else {
# enter error handing code here
}
$geo = str_getcsv($data);
$lat1 = $geo[4];
$lon1 = $geo[5];
//End Web Service Code
}
//GET PRCs
$prc_result = mysql_query("SELECT * FROM prc_info")
or die(mysql_error());
//$prctotal = mysql_num_rows($prc_result);
print "
";
$count = 0;
while ($row = mysql_fetch_array($prc_result)) {
$prc = $row['name'];
$location = $row['location'];
$prcState = $row['state'];
$prcPhone = $row['phone'];
$url = $row['website'];
$lat2 = $row['latitude'];
$lon2 = $row['longitude'];
$theta = $lon1 - $lon2;
$dist = sin(deg2rad($lat1)) * sin(deg2rad($lat2)) + cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($theta));
$dist = acos($dist);
$dist = rad2deg($dist);
$miles = $dist * 60 * 1.1515;
$distance = 30;
if ($miles <= $distance) {
$count = 1;
if ($url == '') {
?>
<div id="prc-spacing"><table cellpadding="2" width="100%"><tr>
<td valign="top"><img src="/images/preg-icon.png" align="left" style="padding-bottom:10px;"></td>
<td valign='top'><a href="prc-info?prc=<?php echo $prcid; ?>">
<?echo $prc;?></a><br>
<?print "$location, $prcState ($prcPhone)";?>
</td></tr></table>
</div>
<?php
}else {
?>
<div id="prc-spacing"><table cellpadding="2" width="100%"><tr>
<td valign="top"><img src="/images/preg-icon.png" align="left" style="padding-bottom:10px;"></td>
<td valign='top'><a href="<?echo $url;?>" target="_blank" onClick="recordOutboundLink(this, 'Outbound Links', 'PRC-<?print "$prc ($prcCity, $prcState)";?>');return false;"><?echo $prc;?></a><br><?print "$location, $prcState ($prcPhone)";?></td></tr></table>
</div>
<?php
}
}
}
if ($count == 0) { ?>
<?php
}
print "
";
?>
[/php]
So appreciate everyone’s expertise and helping me understand so I can hopefully someday be a guru too!
Warm Regards,
Diana