[thelist] php variables in mysql output

Liz Lawson lizlawson at charitycards.co.uk
Mon Dec 4 08:13:24 CST 2000


I want to hold some snippets of html in a mysql db (used to vary messages /
images depending on date rather than using hardcoded "if else else"), but I
need them to include PHP variable names. If I just echo out the result the
variable name is printed as a string ($foo is just "$foo").

  I can see two ways of doing this:

1. Instead of holding the html in the db and doing $topgraphic = stuff from
db, hold the names of include files which hold the actual html and use
something like $topgraphic = include($filenamefromdb). I don't like this
because of the possibility that a file specified in the db isn't there

2. use str_replace() or similar to replace the variable name in the string
with the variable value.

But I wondered if PHP already had the functionality for handling variables
in db output, and I just don't know how to use it.

thanks for any help

Liz

Liz Lawson
Web Designer, The Greetings Card Company Limited
www.charitycards.co.uk






More information about the thelist mailing list