Android Question I Need Conversion of GoogleMap with marker from SQLite to PHP_MYSQL Version

omo

Member
Licensed User
Please, help me!
The attached file below populates markers from sqlite database, i don't have issues with using sqlite with google map and handling other semi-advanced issues after wonderful people like Erel, Don Manfred, Klaus, Mashiane (comprehensive php/mysql tutorial) and entire forum members had resolved my issues relating to google map in one way or the other in the past (God bless you all!). Now, what i need is to convert the code below (or anybody can give me another sample code) that populates custom markers on google map from mysql database using only php and b4a. I have tried several times to convert with no success, i don't have issues with handling CRUD operations in php/mysql, but showing custom markers have been giving me sleepless night since many days now.
 

Attachments

omo

Member
Licensed User
Yes, I already know about security issues like SQL injection and others discussed in the forum concerning PHP and mysql and measure to improve security. The provision and resources I have right now is for PHP and Mysql and I have gone far in the app except how to display googlemap custom marker from mysql. However, about jrdc2, I can only handle simple program with it, once, it gets to complex coding, I get lost with the structure. I have not been able to see comprehensive tutorial when it comes to complex coding and program flow, i can connect to jrdc2 server, I can do CRUD operation and simple stuffs, but getting to complex coding structure, I get lost. At moment, I will be happy if I can get help converting the attached file above to PHP mysql version as stated in the question.
 

omo

Member
Licensed User
Thank you DonManfred, honestly, I can't even state what/where the problem lies, but I know if the simple google map that shows customized marker from mysql_php or the one attached above is converted for me to PHP mysql. I should be able to adapt it to resolve problems I am facing relating to my application.
 

omo

Member
Licensed User
OK, I will try and upload mysql, php and b4a where I guess problem might lie together. Thank you!
 

omo

Member
Licensed User
Things to Note:
I used FusedLocationProvider library to obtain user's latitude and longitude through cell/telecommunication network to replace GPS as used in Erel's Background Tracking Location code. After the main activity loads, between 30 to 50 seconds, it gives latitude and longitude through global variables defined under 'tracker1' service module. These latitude and longitude and other variables defined in the program are used to perform some calculations before sending the results to SQL query in PHP. Running the program, map is showing but no marker is been populated from database. I have checked and re-checked, but to no avail.
 

DonManfred

Expert
Licensed User
Querying
SELECT userfname, usersurname, usersex, userpic, userlongitude, userlatitude, (46.95 - userlatitude) * (46.95 - userlatitude) * 12364.311711488797 + (7.44 - userlongitude) * (7.44 - userlongitude) * 5761.674728278077 AS Distance FROM users WHERE Distance <= 2250000.0 ORDER BY Distance ASC
from a database results in a mysql-error. This is the sql query your php is generating.
#1054 - Unknown column 'Distance' in 'where clause'
the answer to your action mapfrag is always empty as of the mysql-Error.
 
Last edited:

omo

Member
Licensed User
With Distance, I am trying to create 'Distance' column from the query programatically. However, if it is not possible that way, I have another column in mysql database called 'userdistance' which you can use if 'Distance' can not be generated from Query programmatically. Although, 'Distance' is generated programmatically in the first post attachement when used in SQLITE. Thank you very much for assistance!
 

omo

Member
Licensed User
In the query, it was created programmatically with 'as Distance' in Sqlite, when converting to PHP, maybe 'as Distance' is not recognised or what?
 

DonManfred

Expert
Licensed User
Things to note too:

- You are using an VERY VERY OLD httputils module. I have replaced it with okhttputils modules.
- I have changed all call to use multipartpost as this is the most interesting here and you dont need to convert a map to a query manually (it is the wrong solution). See my changes in your code.
 

omo

Member
Licensed User
DonManfred, My standing ovation for you! I delayed in getting back to you so I can cool down to check it and know where again I may be having problem adapting it to my need. I have seen all the changes you made and your comment, I will learn a lot from it. However, getting it adapted to my local wamp server is not giving me result at moment, but I know it should be something to overcome after more research. I will post back the report +ve or -ve after much trial. Thank you!
 

omo

Member
Licensed User
What does "+ve" and "-ve" mean?
Sorry for Delay Response,
+ve (positive response) means if i am able to convert and run your wonderful solution, i will report back to you.
-Ve (Negative response) means if i exhaust all my energy trying to adapt or run this your wonderful solution, but due to some technical issues beyond my power can still not do so, then i will still report back to you.
 
Top