YourDirector Posted November 3, 2010 Share Posted November 3, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/217663-how-to-query-an-html-page-from-mysql/ Share on other sites More sharing options...
fenway Posted November 7, 2010 Share Posted November 7, 2010 Sorry, I don't understand the question. You can store text in the database, and lay it out on the page with php however you'd like. Quote Link to comment https://forums.phpfreaks.com/topic/217663-how-to-query-an-html-page-from-mysql/#findComment-1131381 Share on other sites More sharing options...
wigwambam Posted November 7, 2010 Share Posted November 7, 2010 <? // 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> Quote Link to comment https://forums.phpfreaks.com/topic/217663-how-to-query-an-html-page-from-mysql/#findComment-1131499 Share on other sites More sharing options...
jdavidbakr Posted November 11, 2010 Share Posted November 11, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/217663-how-to-query-an-html-page-from-mysql/#findComment-1133231 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.