Jump to content

Archived

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

piznac

calling var from inside mysql record set?

Recommended Posts

Is it possible to have this:

[quote]<?php
$i = "123";
?>

//get recordset from DB where this is part of it:

recordset results = <table width="188" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td><?php echo $i ?></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
  </tr>
</table>[/quote]

This may be a little hard to understand. But inside my database I have some HTML,.. with some PHP statements inside. They are not working at all. Anybody have any insight?

Share this post


Link to post
Share on other sites
No. What happens there is the php code simply gets sent to the visitor's browser instead of being evaluated by the server.

You can't do this either:

[code]<?php
echo("<?php echo('boo'); ?>");
?>[/code]

Share this post


Link to post
Share on other sites
ok,.. do you know if I could replace something in the string to make it work or something?

Share this post


Link to post
Share on other sites
You could put in some keyword and replace it with variables when printing.

Let's say you put "<p>LOL</p><p>LAL</p>" in the database

then when printing the string

[code]<?php
$replace_pairs = array("LOL" => $i, "LAL" => $j);
echo(strtr($string_from_database, $replace_pairs));
?>[/code]

Or sth

Share this post


Link to post
Share on other sites

×

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.