Using PHP & MySQL to display web pages

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • AF

    Using PHP & MySQL to display web pages

    I am a real novice to php and MySQL, with about a week's worth of
    reading and self tutoring. I have an urgent need to publish a
    database of information and need some guidance on how to do this.

    This question might be more suited to a MySQL newsgroup, but since php
    and MySQL seem to have become almost married to one another, and since
    getting the data out and displaying it is where my problem seems to
    lie, I thought I would start with this php group.

    The problem is I can not figure out how to put information into a
    MySQL database and get it out and correctly dislay it for the web.
    More correctly I have two types of data I need to get in and out.

    1. I have some web page content, not inlcuding borders, that is in
    html format. So I have tried saving the html code, which looks
    exactly like the code when you "view source" on a web page, into MySQL
    and getting it out. I can get it out, but I have not figured out how
    to make it act like html, i.e. to be interpreted by the browsers.
    Instead it comes out looking exactly like html code. It is not being
    interperted by the browser.

    2. I would prefe instead of typing in html code for the content of a
    page to type in instead the text, tables, lists, etc. Here is where
    my problem lies, how do I input to MySQL relatively simple web pages
    that may have a table, a list, some links, a picture?

    3. How do I call up and use the data from MySQL an dget this to
    display for the web?

    By the way, I have been learning css, so I would like to use this if
    possible. If not, i.e. if the formating mechanism for getting content
    into a database precludes having it formattted by css on the
    publication sie, then that is ok. I can live with that.

    Thanks for any help



    Cheers to everyone,

    Al


  • Geoff Berrow

    #2
    Re: Using PHP & MySQL to display web pages

    I noticed that Message-ID: <bjdt905irdp1ui 0o7oed30356oe4v aqc5s@4ax.com>
    from AF contained the following:
    [color=blue]
    >1. I have some web page content, not inlcuding borders, that is in
    >html format. So I have tried saving the html code, which looks
    >exactly like the code when you "view source" on a web page, into MySQL
    >and getting it out. I can get it out, but I have not figured out how
    >to make it act like html, i.e. to be interpreted by the browsers.
    >Instead it comes out looking exactly like html code. It is not being
    >interperted by the browser.[/color]

    It most certainly should be. I'm afraid we need code to see what you
    are doing wrong. Are you saving the file with the extension .php?[color=blue]
    >
    >2. I would prefe instead of typing in html code for the content of a
    >page to type in instead the text, tables, lists, etc. Here is where
    >my problem lies, how do I input to MySQL relatively simple web pages
    >that may have a table, a list, some links, a picture?[/color]

    Usually PHP is used to populate an existing table (or generate a dynamic
    table) from data stored in a database. Pages can consist of html parts
    and PHP parts but when the server has finished the PHP is processed and
    only the output gets sent to the browser.

    e.g.

    <html>
    <body>
    <?php
    print "Hello World";
    ?>
    </body>
    </html>

    is sent to the browser as

    <html>
    <body>
    Hello World
    </body>
    </html>

    --
    Geoff Berrow (put thecat out to email)
    It's only Usenet, no one dies.
    My opinions, not the committee's, mine.
    Simple RFDs http://www.ckdog.co.uk/rfdmaker/

    Comment

    • Theo

      #3
      Re: Using PHP &amp; MySQL to display web pages

      AF <bscinc3000@NOS PAMYahoo.com> wrote in
      news:bjdt905ird p1ui0o7oed30356 oe4vaqc5s@4ax.c om:
      [color=blue]
      > I am a real novice to php and MySQL, with about a week's worth of
      > reading and self tutoring. I have an urgent need to publish a
      > database of information and need some guidance on how to do this.[/color]

      I am quite new myself. php.net has alot of tutorials. mysql really isnt
      that hard, except for the admin stuff, which I think is a pain. But
      phpmyadmin helps alot, and its free. Installing it takes a little care...
      its not like installing photoshop. But follow the instructions and it will
      work. Later, you can write your own simple HTML form pages with php so you
      can do simple editing of tables.

      You do have apache, mysql, & php I assume.

      And yes there is alot of info in the SQL newsgroup.

      Comment

      • AF

        #4
        Re: Using PHP &amp; MySQL to display web pages

        On Mon, 10 May 2004 00:24:03 +0100, Geoff Berrow
        <blthecat@ckdog .co.uk> wrote:

        snip..[color=blue]
        >Usually PHP is used to populate an existing table (or generate a dynamic
        >table) from data stored in a database. Pages can consist of html parts
        >and PHP parts but when the server has finished the PHP is processed and
        >only the output gets sent to the browser.
        >[/color]

        Let me give you an example of what I want to do:

        here is a url:

        http://www.improvingyo urhome.com/homestore.nsf/32a793ea58ba3df 585256e5c005f5f 66/f348bc1ba98fa17 685256e59005cbc 58!OpenDocument

        If you go look at it, you will see a list in the middle of the page.

        Here is the page without the <li>

        Abundant Earth offers a wide variety of environmentally sensitive
        products and services for people who want to make a difference in the
        world.

        Departments include:

        Air Purification
        Bags & Packs
        Beds & Bedding
        Candles - Holders
        Cards - Journals
        Children - Fun
        Cleaning
        Coffees & Teas
        Energy Savings & Conservation
        Gifts & Crafts
        Health Wellness
        Hemp & More
        Home Furnishing
        Jewelry
        Kitchen & Bath
        Lawn & Garden
        Personal Care
        Pets & Wildlife
        Platform Beds
        Recycled Items
        Vitamins & Supplements
        T-Shirts
        Water Purification


        The list starts at "Air Puritfication".

        Now I think I can solve my other problem in my original post. I am
        sure there is something I have done wrong.

        But getting a page's content that contains a list like the above or a
        table is not shown, or at least I can't find it.

        Imagine for example you were to create a simple Word doc that
        contained a list and a table, and now you want to show that Word doc
        on the web as an html page. But you want the contents of the Word doc
        to be in a field and then have that field displayed.

        Is there something like a "rich text field" in MySQL and can php
        display this field in html?


        Cheers to everyone,

        Al


        Comment

        • Tim Van Wassenhove

          #5
          Re: Using PHP &amp; MySQL to display web pages

          In article <4igt905mdv5ptf ul3m3pdn8fouop4 39pub@4ax.com>, AF wrote:[color=blue]
          > Let me give you an example of what I want to do:
          >
          > But getting a page's content that contains a list like the above or a
          > table is not shown, or at least I can't find it.[/color]

          If i understand you right: You have a page in your database. That page
          itself has a list that should be built dynamically.

          In that case you might want to have a look at the eval function in the
          manual.


          --

          Comment

          • Five Cats

            #6
            Re: Using PHP &amp; MySQL to display web pages

            In message <4igt905mdv5ptf ul3m3pdn8fouop4 39pub@4ax.com>, AF
            <bscinc3000@NOS PAMYahoo.com> writes
            <snip>[color=blue]
            >
            >Is there something like a "rich text field" in MySQL and can php
            >display this field in html?
            >[/color]
            There are a variety of text fields in MySQL, but none of them are the
            kind of 'rich text' field you want. You would have to populate them
            with the correct HTML to produce the result you wanted in the browser.

            See:






            I would expect your PHP page to generate some of the required HTML and
            extract some parts from the database, so to generate a list it would
            contain:
            <ul><li>1st tiem</li><li>second item</li></ul>

            And you would have to type in (or otherwise generate) the correct tags
            yourself.

            At the end of the day the PHP script has to generate the complete HTML
            that you would write to produce the desired page. It can do that by a
            mixture of bits of HTML in the PHP script outside the <? ?> sections
            (e.g. the sections that contain the PHP code), bits of HTML that are
            printed as literals inside the <? ?> sections, and bits of HTML that are
            extracted from a database again inside the <? ?> sections.
            [color=blue]
            >
            >Cheers to everyone,
            >
            >Al
            >
            >http://www.discountdrivingschool.com[/color]

            --
            Five Cats
            Email to: cats_spam at uk2 dot net

            Comment

            • AF

              #7
              Re: Using PHP &amp; MySQL to display web pages

              On Mon, 10 May 2004 08:56:20 +0100, Five Cats <cats_spam@[127.0.0.1]>
              wrote:

              snip...[color=blue][color=green]
              >>[/color]
              >There are a variety of text fields in MySQL, but none of them are the
              >kind of 'rich text' field you want. You would have to populate them
              >with the correct HTML to produce the result you wanted in the browser.
              >[/color]

              You have an accurate picture of what I want to do. How do really big
              sites, like About.com, input all of their articles? I can see how to
              handle pictures, but what about tables and lists that are part of my
              page content?

              Do they use languages that do have this kind of field? Or do they
              just input the code for the whole content?

              In the example I posted:

              "Abundant Earth offers a wide variety of environmentally sensitive
              products and services for people who want to make a difference in the
              world.

              Departments include:

              Air Purification
              Bags & Packs
              Beds & Bedding
              Candles - Holders
              Cards - Journals
              Children - Fun
              Cleaning "

              is there a way to post this with a pseudo html, something like this:

              "Abundant Earth offers a wide variety of environmentally sensitive
              products and services for people who want to make a difference in the
              world.

              Departments include:

              <li>Air Purification
              <li>Bags & Packs
              <li>Beds & Bedding
              <li>Candles - Holders
              <li>Cards - Journals
              <li>Children - Fun
              <li>Cleaning "

              The point being that a paragraph needs no code to be rendered
              properly, but the list of items does.

              This would be doable from an input point of view. But if I had to add
              the <br>'s and other code in order to render the whole page that would
              be very inefficient.

              What about all of these content management systems I see? They have
              fields that allow bold, italics, centering, fonts changes in size and
              color. How do they handle the code?

              Do they convert the field I would input into html and then save it?

              Thanks to everyone that has posted.

              Cheers to everyone,

              Al


              Comment

              • Five Cats

                #8
                Re: Using PHP &amp; MySQL to display web pages

                In message <ejmu90l2hbkjrv rbskoj4ejv60peg sgu4m@4ax.com>, AF
                <bscinc3000@NOS PAMYahoo.com> writes[color=blue]
                >On Mon, 10 May 2004 08:56:20 +0100, Five Cats <cats_spam@[127.0.0.1]>
                >wrote:
                >
                >snip...[color=green][color=darkred]
                >>>[/color]
                >>There are a variety of text fields in MySQL, but none of them are the
                >>kind of 'rich text' field you want. You would have to populate them
                >>with the correct HTML to produce the result you wanted in the browser.
                >>[/color]
                >
                >You have an accurate picture of what I want to do. How do really big
                >sites, like About.com, input all of their articles?[/color]

                I can't say as I can only see what they produce.
                [color=blue]
                > I can see how to
                >handle pictures, but what about tables and lists that are part of my
                >page content?
                >
                > Do they use languages that do have this kind of field? Or do they
                >just input the code for the whole content?
                >
                >In the example I posted:
                >
                >"Abundant Earth offers a wide variety of environmentally sensitive
                >products and services for people who want to make a difference in the
                >world.
                >
                >Departments include:
                >
                >Air Purification
                >Bags & Packs
                >Beds & Bedding
                >Candles - Holders
                >Cards - Journals
                >Children - Fun
                >Cleaning "
                >
                >is there a way to post this with a pseudo html, something like this:
                >
                >"Abundant Earth offers a wide variety of environmentally sensitive
                >products and services for people who want to make a difference in the
                >world.
                >
                >Departments include:
                >
                ><li>Air Purification
                ><li>Bags & Packs
                ><li>Beds & Bedding
                ><li>Candles - Holders
                ><li>Cards - Journals
                ><li>Children - Fun
                ><li>Cleaning "
                >
                >The point being that a paragraph needs no code to be rendered
                >properly,[/color]

                Possibly - but see the comment on CSS below.
                [color=blue]
                > but the list of items does.
                >
                >This would be doable from an input point of view. But if I had to add
                >the <br>'s and other code in order to render the whole page that would
                >be very inefficient.[/color]
                What <br> would that be?

                Departments include:
                <ul>
                <li>Air purification</li>
                etc.
                </ul>

                The tags have to be there in the final analysis.
                [color=blue]
                >
                >What about all of these content management systems I see? They have
                >fields that allow bold, italics, centering, fonts changes in size and
                >color. How do they handle the code?
                >
                >Do they convert the field I would input into html and then save it?[/color]

                Have never seen or used one so cannot comment, but I'm sure that style
                sheets are part of it as well so that it's easy to alter the style of a
                given type of element without having to alter all the pages or whatever.

                They might be storing the stuff as XML and doing things to it on it's
                way out.

                There are lots and lots of ways of doing things, so as the questions get
                more & more detailed it gets harder & harder to provide answers as what
                comes into my head are more & more questions.... ;-)
                [color=blue]
                >
                >Thanks to everyone that has posted.
                >
                >Cheers to everyone,
                >
                >Al
                >
                >http://www.discountdrivingschool.com[/color]

                --
                Five Cats
                Email to: cats_spam at uk2 dot net

                Comment

                Working...