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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.