Hey all, I've got quite a few questions that I feel are a little heavy for posting in QTDNTOT. If they belong there feel free to yell at me. :v:
So I'm new to PHP, mySQL, and web design and web development as a whole. A few years back I taught myself basic HTML and CSS to create my [url=http://candy.roalviro.com/]personal website[/url], but then never finished it nor took it anywhere. I'm now in a PHP with mySQL course and have been hired by a classmate to work on the website for his start-up company. Currently I've gotten the base HTML and CSS down along with a few other things, but I need advice and help on where to go with what he needs. I will NOT be asking for code to be written for me.
The site is for breast cancer. It aims to be localized to the site's users, aiding in finding local support groups, clinics, and physicians. The clinics will pay for advertising space on the site (that portion is already covered), so I need to write a way to serve up the ads, showing the end user the closest clinic to them. I found an [url=http://ipinfodb.com/ip_location_api.php]IP to Location API[/url] that generates country (the site will eventually go international, so this is good), state, city, zip, and long-/lat-itude. I figure I'll store this information in a cookie. What I'm wondering is what would be the best way to then figure out which clinic is closest to them and subsequently serve the ad. My thoughts were to have a database of the clinics with the same info. I'm not entirely sure which field to compare, though. Long/lat would be simple arithmetic but not necessarily the best method? Zip codes are well documented, but I think coding an app to do the comparison could get tedious, and I'm not even sure where to start with comparing city/state proximities.
And then the ads themselves. What's the most efficient way to store them? Would I want to store a reference in the clinic database in a field? Something like an ad field that contains a link to a .html or plain text file that's just the ad, which is then loaded into the page? Would I want to have an ad field that stores a plain text code for the ad? What would be the best course of action to take for this? I'm trying to think in terms of both ease of coding (especially since I'm entry level) and efficiency.
The final question (at least, that I can remember right now) is about a CMS. Eventually (though it's not required for now), he wants to implement a CMS. The requirements are:
[quote]1) the ability for end users (in this case, the clinics) to enter and modify information with no knowledge of html/css
2) the ability to stage work so it can be seen on a development site before it's published
3) scheduling and managing ads
4) workflow management so there's a way of specifying who (or which groups) have to work on and/or approve things before they are published along with the ability to specify dates when articles are active / inactive.[/quote]
I've looked a little into Drupal, Joomla!, and Concrete5. I'd just like personal experiences and opinions on what each software does. They all have their ups and downs, and looking at each, none of them seem to do it all in a way that doesn't create a second job for someone. I was hoping for something that could automate the process, but each one seems to have a lot of manual work involved to do what's required. Other suggestions are fine, but I'm not looking for you to do my research for me.
Thanks in advance, everyone.
As for figuring out the nearest clinic, I'd personally go with long/lat simply because it is the most simple. IP to location conversion is never accurate, so you're always going to have accuracy issues - the inaccuracy of the long/lat of the individual clinics is negligible when compared
ZIP code would be tougher. I'm not even sure how i'd do that!
By state should be simple enough. You'd need a way to rank how close states are to one another, but that can be done by taking the long/lat of the city centre or state centre and taking the absolute distance between them - you could then list the nearest states, showing ads for the state nearest (if the current state doesn't have clinics or something)
But personally, long/lat would be easier and would return more useful results (most of the time)
I remember getting very accurate results with the google gears api. Too bad it got shut down.
It was a geolocation based message/advertisment system. Users could either use the mobile app or a pc to post messages at their current location. Simply storing it in a database using user+id+message+long+lat. That message could be pretty much anything. Like:
"I lost my dog here, please call 123456 if you see this dog - pic here - "
People opening the webpage or app around that would see that message first, the further away the message was the lower on the list it would appear.
I believe its something similar you want to do but only allow clinics to add messages? Add all the clinics with an unique id to a database. Then just compare the users current location with the closest clinic using long/lat and show the uploaded text/image/(what ever the clinic uploaded as ad) with the same id as the clinic.
Alright, I've been working on trying to get the code working. Unfortunately, the snippet that had been given on the API site no longer seems to work.
[code]<?php
include_once('ip2locationlite.class.php');
//Set geolocation cookie
if(!$_COOKIE["geolocation"]){
$ipLite = new ip2location_lite;
$ipLite->setKey('<your_api_key>');
$visitorGeolocation = $ipLite->getCountry($_SERVER['REMOTE_ADDR']);
if ($visitorGeolocation['statusCode'] == 'OK') {
$data = base64_encode(serialize($visitorGeolocation));
setcookie("geolocation", $data, time()+3600*24*7); //set cookie for 1 week
}
}else{
$visitorGeolocation = unserialize(base64_decode($_COOKIE["geolocation"]));
}
var_dump($visitorGeolocation);[/code]
I'd tested it in class on a wamp server and it worked fine. var_dump dumped all the info that I needed. Now it's telling me (on my desktop, using xampp) that there's an undefined index "geolocation" on line 5. Which is the line for checking if the cookie exists. I've tried modifying it to if(!isset($_COOKIE[...])){, and it still doesn't work. I'm not really sure what to do from here since the code should work (at least, logically) and I don't know of any other ways to do it. I mean, it's telling me it doesn't when it's coded to be checking that exact thing.
Why not check if the cookie has something set in it, rather than if it exists?
Well it helps if I actually drag the updated files from my flash drive to my htdocs folder. :downs:
Right now it's still sitting at NULL for the value, but it's found the value. To be expected since the API tends to break when hosted and accessed from a local machine.
I am working on a site right now that deals heavily with locations stored in MySQL and displayed on a map that are fully customizable to the users.
All my locations are stored with the latt/long, name, formatted address, description... etc in mysql.
if you want location based tools that can be displayed and calculated, I rely on a jQuery library called [url=http://gmap3.net/]Gmap3[/url] that uses the Google maps API easier than using the API itself. (if you're not familiar with [url=http://jquery.com/]jQuery[/url], its a javascript library that is very simple and powerful)
with Gmap3 you can use your database to to show all your locations on a map, plot distance and even directions.
calculating the closest clinic like you said should be fairly simple comparing your ip to a list of others that can be narrowed down by state. (example MySQL: "SELECT * FROM clinics WHERE state='$currentstate' ")
unfortunetly I don't have much experience in Drupal, Joomla!, or Concrete5 to give much advice.
Sorry, you need to Log In to post a reply to this thread.