You are here: Re: [PHP] PHP code in a MySQL record « PHP « IT news, forums, messages
Re: [PHP] PHP code in a MySQL record

Posted by Andrι Medeiros on 07/30/05 02:24

Either what Kris says, or you can use a templating engine.

See Smarty (http://smarty.php.net)

On 7/29/05, Kristen G. Thorson <kthorson@allegroconsultants.com> wrote:
> Is there a particular reason you need *PHP* in the database? If not,
> then use a placeholder system of some sort ( like #var# ) and str_replace():
>
> while( $row=mysql_fetch_row($result) ) {
> echo str_replace( '#var#', $that_var, $row['entry'] );
> }
>
>
>
> kgt
>
>
>
>
> Nathaniel Hall wrote:
>
> >I am working on a project that uses an index.php page. Depending on the
> >variable in the URL, a different php page is included. I have a
> >config.php that contains variables that are accessible from any page.
> >That is the easy part.
> >
> >I have some pages pulling HTML out of a database. I would like to be
> >able to reference some of the variables in the config.php in the
> >database blob field. Here is an example:
> >
> >index.phphalln_\@_otc_\._edu
> >------
> ><html><head>...etc
> ><?php
> > include 'config.php';
> > if (blabla) {
> > include "thispage.php";
> > } else {
> > include "thatpage.php";
> > }
> >?>
> >
> >config.php
> >------
> ><?php
> > $this_var=1;
> > $that_var="Nothing";
> >?>
> >
> >test.php
> >------
> ><?php
> > $query="SELECT * from table";
> > $result=mysql_query($query) or die ("Cannot process query");
> > $row=mysql_fetch_row($result);
> > echo $row[1];
> >?>
> >
> >MySQL record:
> >------
> >id,year,month,day,entry
> >
> >1,2005,01,01,This is a test<br><? echo $that_var; ?>
> >
> >_____________________________
> >I have tried using <br>&gt;? echo $that_var; ?&lt; and I have tried
> >escaping everything, but that still didn't work. Any ideas?
> >
> >Nathaniel Hall
> >halln_\@_otc_\._edu
> >
> >
> >
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

 

Navigation:

[Reply to this message]


УдалСнная Ρ€Π°Π±ΠΎΡ‚Π° для программистов  •  Как Π·Π°Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π½Π° Google AdSense  •  England, UK  •  ΡΡ‚Π°Ρ‚ΡŒΠΈ Π½Π° английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация