php/Mysql help

Hi guys. I have been searching the forum for hours and I can not seem to find any help for a problem I am currently getting.

Im currently trying to expand my knowledge of PHP and MYsql, I wouldnt say I was a advanced user in anyway and I would imagine the soloution to my problem is quite simple.

I currently have a database set up,
Users with the fields, id, name, distance in it. another table called locations which has id, name, distance in it.
What I want to do is have a drop down menu or a tick box menu with the locations on it and when a user selects a location the distance in the locations table is subtracted from the distance in the users table…

Are you having trouble creating the dropdowns? Once the info is inside the dropdowns, just subtract them. Perhaps it is the dropdown format you do not understand. You can use the “VALUE” inside of a dropdown as anything you want to use. So, let’s say, you have have names of cities and distance from NYC. One might be “Chicago, Ill”, 1000 and another “South Bend, Neb.”, 2400… Whatever…
You can code an option inside of the SELECT something like this:

Chicago, Ill
South Bend

The data inside the value is for your use and the text is outside of this. (Of course this is pulled from
your database when you build the OPTION list!) Then, when the form is posted, you can use the data
like this… $difference = $_POST[‘City1’] - $_POST[‘City2’];
Of course, this is just a wild sample to get you thinking… Good luck…

Think i got it but I will have to play around tomorrow,sleep is calling…

Thanks alot

Sponsor our Newsletter | Privacy Policy | Terms of Service