Calling a variable from a db table output

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
pinehead18
Forum Contributor
Posts: 329
Joined: Thu Jul 31, 2003 9:20 pm

Calling a variable from a db table output

Post by pinehead18 »

Example

***** PLEASE USE TAGS FOR CODE *****

Code: Select all

$sql = mysql_query("SELECT html FROM html");
$row = mysql_fetch_array($sql);


$html = $row['html'];
$body = "i'm the body";
$html then has the output of <html>$body</html>

but $html wont look at the variable $body.

Any ideas?
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

What do you mean "$html wont look at the variable $body" ? How does a variable "look" at another variable?
(#10850)
pinehead18
Forum Contributor
Posts: 329
Joined: Thu Jul 31, 2003 9:20 pm

Post by pinehead18 »

Well when $html = <body>$body</body> that is the data in the table.

I want it to somehow call $body.

can it not?
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

pinehead18 wrote:Well when $html = <body>$body</body> that is the data in the table.

I want it to somehow call $body.

can it not?
You can "call" a variable. $html is being assigned the value in $row['html'] which is in the database. If you then do $html = "<body>$body</body>"; then $html will now contain "<body>Whatever body variable contained</body>".
(#10850)
User avatar
crystal ship
Forum Commoner
Posts: 36
Joined: Wed Aug 29, 2007 5:45 am

Post by crystal ship »

What is the real problem? Clearify. I can't get any clue here. What are you really trying to do?
Post Reply