Hi there,

Is it possible for PHP to select a table in the database which contains a full html code document and then display it for the user to view?

If yes, can someone guide me in the right direction as to how I would do this?

Many thanks!

    It is certainly possible. (Whether or not it's the best solution for your particular requirements is a separate question I can't answer at this point.) When you get right down to it, HTML is just plain text which can easily be stored in a database in a text type of column. If using MySQL, for example, you could use the conveniently named "TEXT" type of column. 😉 You would presumably have other columns used to identify that page so that you can select it via an appropriate WHERE clause in an SQL SELECT query. Upon a successful query, you simply [man]echo[/man] out the contents of that field.

      Thanks for your reply.

      So if I echoed the html code, let's say one line echoed was something like:

      Number of Users: 500

      Would it be possible for me to echo the number of users that are echoed from the html code from the database?

      i.e Could I use the data collected from the html document for other mysql queries on the same php page?

        Ok, just wondering if anyone can help me here?

        Basically, I just want to echo a certain part of the html from mysql database, not the whole thing.

        Is that possible? I think i'd have to use wildcards but can someone help me out? I'd appreciate it. Thanks!

          It will be pretty tricky unless the part you are after are very well defined which then would be extracted with regular expressions or other string functions.
          I read that you store the whole html page as one text field in the DB which means that there is a whole bunch of stuff to parse through.

          You should maybe try to break it down in smaller pieces. Using templates is not a bad idea either which will make your life much easier as far as finding certain items.

          It all boils down how you want to handle your content.

            Write a Reply...