chordsoflife Posted December 30, 2008 Share Posted December 30, 2008 Should be simple for you gurus.. I've got some google maps code stored in a database, and I changed the width and height they gave me to width="<? $mapWidth ?>", etc. When I echo this out, I literally get that php code. Helps? Quote Link to comment https://forums.phpfreaks.com/topic/138844-solved-php-from-database/ Share on other sites More sharing options...
daveoffy Posted December 30, 2008 Share Posted December 30, 2008 did you set $mapWidth to $row['mapwidth'] or whatever? Quote Link to comment https://forums.phpfreaks.com/topic/138844-solved-php-from-database/#findComment-726022 Share on other sites More sharing options...
chordsoflife Posted December 30, 2008 Author Share Posted December 30, 2008 Well, no, maybe I'm not clear. I don't have each stored individually. I have a column in a database named fldMap. In there, I have the HTML Google gives you from Google Maps. However, that HTML contains a few things I want to retain control over, so I stored the block of code in the database with variables for the parameters I wanted to change. The problem is, when I output the code from the database (which works just fine), the what SHOULD be parameters output as PHP (like, I view the source and see PHP). Quote Link to comment https://forums.phpfreaks.com/topic/138844-solved-php-from-database/#findComment-726024 Share on other sites More sharing options...
daveoffy Posted December 30, 2008 Share Posted December 30, 2008 Well from what you say it seems like you just need to add echo $mapWidth; Quote Link to comment https://forums.phpfreaks.com/topic/138844-solved-php-from-database/#findComment-726025 Share on other sites More sharing options...
RussellReal Posted December 30, 2008 Share Posted December 30, 2008 I've done something like this.. its probably not the most efficient way.. but its a way I know to do it.. after you collect the data from the database lets say you put the data into a variable called like $data you could do something like <?php // do all the mysql stuffslol make sure $data has the google maps code or w\e if (!is_dir("temporaryDirectory")) { mkdir("temporaryDirectory"); } $file = "temporaryDirectory/".md5($_SERVER['REMOTE_ADDR'].rand(1,50)).".php"; $tempFile = fopen($file,'w'); fwrite($tempFile,$data); fclose($tempFile); ob_start(); include($file); $contents = ob_get_clean(); ob_end_clean(); unlink($file); // now put $contents wherever you want your map thingy to show up ?> Quote Link to comment https://forums.phpfreaks.com/topic/138844-solved-php-from-database/#findComment-726029 Share on other sites More sharing options...
chordsoflife Posted December 30, 2008 Author Share Posted December 30, 2008 Here's what I wound up doing: $replaced = array('mapWidth', 'mapHeight', 'mapBorder'); $replace = array('500px', '325px', '1'); echo str_replace($replaced, $replace, $row['fldMap']); *tentatively solved, anyway. Quote Link to comment https://forums.phpfreaks.com/topic/138844-solved-php-from-database/#findComment-726037 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.