Jump to content

[SOLVED] PHP From Database


chordsoflife

Recommended Posts

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).

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
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.