Jump to content

How to Query an HTML page from MySQL


YourDirector

Recommended Posts

Hey everyone,

 

I'm very new to MySQL and am currently working on my first MySQL based website. However, what I originally planned to do may have been based on a drastic misunderstanding of what MySQL can be used for. Basically, I wanted to be able to have an HTML page in my MySQL database and use a query to call it on my website. However, If this is possible, I can't figure out how to do it. I understand how to query standard text and figures etc to echo onto a page, but when it comes to the HTML, if I use an echo command it displays nothing. I want it to load the HTML page through this. Is this possible?

 

The current query I am using is:

$result = mysql_query("SELECT * FROM acts")
or die(mysql_error());  
$row = mysql_fetch_array( $result );
echo $row['body'];

?>

This is the query which returns nothing.

 

Thanks for any help you can give.

 

Link to comment
Share on other sites

<?
// Open Database here.
$result = mysql_query("SELECT * FROM acts WHERE page='home'")
or die(mysql_error());  
$row = mysql_fetch_array( $result );
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd"
    >
<html lang="en">
<head>
    <title><? echo $row['title']; ?></title>
</head>
<body>
<? echo $row['body']; ?>

</body>
</html>

Link to comment
Share on other sites

You want to store the content of the pages in a single column in the database?  You can do that, but it's really not any different than using flat files.  Actually, flat files would be far easier to manage.  The responses above are the correct way to use MySQL with a database, put elements into the database that you then use to build the pages.  If your site doesn't need that level of complexity, you're probably better off just using flat files and combining a wrapper file with content files in PHP or something of that nature.

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.