keithschm Posted April 16, 2007 Share Posted April 16, 2007 I am using a google API script to show a map with many points. I am pulling city and state and names from a mysql database. I can pull the info correctly, but can't seem to format the $var properly it should look like $map->addMarkerByAddress('621 N 48th St # 6 Lincoln NE 68502','PJ Pizza','<b>PJ Pizza</b>'); and I have these vars $loc $name I have tried $map2 = 'addMarkerByAddress('; $map2 .=$loc; $map2 .= ','; $map2 .= $name; $map2.= ','; $map2 .= $name; $map2.= ') '; $map->$map2; when I echo it it looks correct, but does not pas the var to the script properlly. I think I am formating it for viewing not sure. also what does -> mean in PHP thanks Link to comment https://forums.phpfreaks.com/topic/47250-vars/ Share on other sites More sharing options...
boo_lolly Posted April 16, 2007 Share Posted April 16, 2007 it means you're using a class. look in my signature under oop. it will explain a lot. to answer your question, the reason why it won't work is because when programming in an object oriented fashion, you must declare your variables. you can't just add one whenever you want to on the fly. Link to comment https://forums.phpfreaks.com/topic/47250-vars/#findComment-230428 Share on other sites More sharing options...
keithschm Posted April 16, 2007 Author Share Posted April 16, 2007 thank you for your reply ok so the script has these lines of code $map->addMarkerByAddress('621 N 48th St # 6 Lincoln NE 68502','PJ Pizza','<b>PJ Pizza</b>'); $map->addMarkerByAddress('826 P St Lincoln NE 68502','Old Chicago','<b>Old Chicago</b>'); $map->addMarkerByAddress('3457 Holdrege St Lincoln NE 68502',"Valentino's","<b>Valentino's</b>"); what would be the best way to pull the info from the datbase? I have the information from my sql statements, and I am looping through the code to pull all if the info Link to comment https://forums.phpfreaks.com/topic/47250-vars/#findComment-230433 Share on other sites More sharing options...
boo_lolly Posted April 16, 2007 Share Posted April 16, 2007 i'm sure your class already has a method for pulling info from your database. by the way, there's an OOP child-forum here. Link to comment https://forums.phpfreaks.com/topic/47250-vars/#findComment-230449 Share on other sites More sharing options...
keithschm Posted April 16, 2007 Author Share Posted April 16, 2007 thanks for all your help. Maybe someone can move this to the correct sub forum. I am sorry that I put it in the wrong forum I am using 2 different database's. one for the geocode caching another that has a user database from my cms. The class came scripted to read and write the cache from a databse. Pulling locations it does not. It looks for these lines in the main file.] map->addMarkerByAddress('621 N 48th St # 6 Lincoln NE 68502','PJ Pizza','<b>PJ Pizza</b>'); $map->addMarkerByAddress('826 P St Lincoln NE 68502','Old Chicago','<b>Old Chicago</b>'); $map->addMarkerByAddress('3457 Holdrege St Lincoln NE 68502',"Valentino's","<b>Valentino's</b>"); I haved added my own code to pull the info from the database that has the information in it. here is my code $query = "SELECT user_id, user_name FROM e107_user where user_name = 'john doe'"; $result = mysql_query($query); while($row = mysql_fetch_assoc($result)) { $map2 = 'addMarkerByAddress('; $userid = $row['user_id']; $query2 = "SELECT user_location FROM e107_user_extended where user_extended_id = $userid"; $result2 = mysql_query($query2); while($row2 = mysql_fetch_assoc($result2)) { $loc = $row2['user_location']; $map2 .=$loc; } $name= $row['user_name']; //echo $name; //echo $row['user_name']; $map2 .= ','; $map2 .= $name; $map2.= ','; $map2 .= $name; $map2.= ') '; $map2 .= '<br />'; } $map->$map2; echo $map; mysql_query($query) or die('Error, insert query failed'); mysql_close($conn); The data is pulling correctly from the database. So how would I send the data to the class. Link to comment https://forums.phpfreaks.com/topic/47250-vars/#findComment-230498 Share on other sites More sharing options...
boo_lolly Posted April 16, 2007 Share Posted April 16, 2007 you have to hack the class itself to be able to retrieve data from an outside source. Link to comment https://forums.phpfreaks.com/topic/47250-vars/#findComment-230508 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.