Trying to build a database driven website

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

    Trying to build a database driven website

    Hello, I'm trying to build a database driven website for a library
    management system. The database is stored on a remote server which all
    of my team mates can access. I've installed MySQL, PHP and Apache on
    my machine. I'm a beginner and I really don't understand how to
    proceed. My biggest problem is how to connect to the database on
    remote mysql server ? Does php allow this kind of thing ? I'm
    interested in a web interface on my machine and a database on reote
    server. Are there any tutorials/books you would like to recommend ?
  • Ivan Marsh

    #2
    Re: Trying to build a database driven website

    On Wed, 24 Sep 2008 12:41:20 -0700, pereges wrote:
    Hello, I'm trying to build a database driven website for a library
    management system. The database is stored on a remote server which all
    of my team mates can access. I've installed MySQL, PHP and Apache on
    my machine. I'm a beginner and I really don't understand how to
    proceed. My biggest problem is how to connect to the database on
    remote mysql server ? Does php allow this kind of thing ? I'm
    interested in a web interface on my machine and a database on reote
    server. Are there any tutorials/books you would like to recommend ?
    PHP is a popular general-purpose scripting language that powers everything from your blog to the most popular websites in the world.


    --
    I told you this was going to happen.

    Comment

    • FutureShock

      #3
      Re: Trying to build a database driven website

      pereges wrote:
      Hello, I'm trying to build a database driven website for a library
      management system. The database is stored on a remote server which all
      of my team mates can access. I've installed MySQL, PHP and Apache on
      my machine. I'm a beginner and I really don't understand how to
      proceed. My biggest problem is how to connect to the database on
      remote mysql server ? Does php allow this kind of thing ? I'm
      interested in a web interface on my machine and a database on reote
      server. Are there any tutorials/books you would like to recommend ?
      I learned tons of PHP and Database integration using this book:

      PHP and MySQL Web development

      # ISBN-10: 0672329166
      # ISBN-13: 978-0672329166

      Scotty

      Comment

      • Rob

        #4
        Re: Trying to build a database driven website

        On Sep 24, 8:41 pm, pereges <Brol...@gmail. comwrote:
        Hello, I'm trying to build a database driven website for a library
        management system. The database is stored on a remote server which all
        of my team mates can access. I've installed MySQL, PHP and Apache on
        my machine. I'm a beginner and I really don't understand how to
        proceed. My biggest problem is how to connect to the database on
        remote mysql server ? Does php allow this kind of thing ? I'm
        interested in a web interface on my machine and a database on reote
        server. Are there any tutorials/books you would like to recommend ?
        Programming PHP from O'Reilly is probably a good place to start -


        Rob.

        Comment

        • doznot

          #5
          Re: Trying to build a database driven website

          pereges wrote:
          Hello, I'm trying to build a database driven website for a library
          management system. The database is stored on a remote server which all
          of my team mates can access. I've installed MySQL, PHP and Apache on
          my machine. I'm a beginner and I really don't understand how to
          proceed. My biggest problem is how to connect to the database on
          remote mysql server ? Does php allow this kind of thing ? I'm
          interested in a web interface on my machine and a database on reote
          server. Are there any tutorials/books you would like to recommend ?
          For what little it's worth, about page generation in the general case:

          I think database driven websites are fine for large complex sites, but
          not so well suited to anything less than large top-dollar installations.

          If so (if large and demanding) Drupal is hard to beat. It does have a
          bit of a learning curve but it's not all that hard to bring online if
          you're content to leave it's native look and feel basically as is. It is
          damn difficult to learn how to really tweak it (I tried but gave up on
          it, I was just fiddling anyway).

          But (for large sites) its page caching is so well done it runs quickly
          and reliably with built in search and half a million plugin modules.
          So, for sites that warrant, you might be better off learning Drupal than
          fighting through building from scratch.

          But if you are determined to roll your own, you might want to consider
          building around a files-based system. If you use a PHP wrapper that
          sucks in files for div contents (rather than behind the scenes mysql
          queries) the system runs faster and it's a hell of lot easier to
          munge the content.

          With a files-based system you can search and replace recursively with
          bash perl and sed, without having to fight with complex sql dumps and
          updates.

          .....I did it with directories. Each page is actually a specially-named
          directory containing files that are html fragments, that get sucked in
          as div contents, where positioning and appearance are controlled (as
          much as possible) by css.

          Comment

          • Jerry Stuckle

            #6
            Re: Trying to build a database driven website

            doznot wrote:
            pereges wrote:
            >Hello, I'm trying to build a database driven website for a library
            >management system. The database is stored on a remote server which all
            >of my team mates can access. I've installed MySQL, PHP and Apache on
            >my machine. I'm a beginner and I really don't understand how to
            >proceed. My biggest problem is how to connect to the database on
            >remote mysql server ? Does php allow this kind of thing ? I'm
            >interested in a web interface on my machine and a database on reote
            >server. Are there any tutorials/books you would like to recommend ?
            >
            For what little it's worth, about page generation in the general case:
            >
            I think database driven websites are fine for large complex sites, but
            not so well suited to anything less than large top-dollar installations.
            >
            I have a lot of database driven sites which are small and definitely not
            "top dollar". It's valid for any time you need dynamic content.
            If so (if large and demanding) Drupal is hard to beat. It does have a
            bit of a learning curve but it's not all that hard to bring online if
            you're content to leave it's native look and feel basically as is. It is
            damn difficult to learn how to really tweak it (I tried but gave up on
            it, I was just fiddling anyway).
            >
            There are others which are also good - Joomla, Smarty, etc. Yes, Drupal
            can be difficult to configure - but it's much more than just a "database
            driven site". It is a full CMS with lots of feature. Something
            entirely different.
            But (for large sites) its page caching is so well done it runs quickly
            and reliably with built in search and half a million plugin modules.
            So, for sites that warrant, you might be better off learning Drupal than
            fighting through building from scratch.
            >
            Actually, I've found it to be just the opposite. I use it and like it -
            but for a large site, I would be looking at something else. Drupal
            requires a lot of system resources (especially CPU).
            But if you are determined to roll your own, you might want to consider
            building around a files-based system. If you use a PHP wrapper that
            sucks in files for div contents (rather than behind the scenes mysql
            queries) the system runs faster and it's a hell of lot easier to
            munge the content.
            >
            What do you think a file system is - other than a simple type of a database?
            With a files-based system you can search and replace recursively with
            bash perl and sed, without having to fight with complex sql dumps and
            updates.
            >
            Even easier to do with a SQL database.

            ....I did it with directories. Each page is actually a specially-named
            directory containing files that are html fragments, that get sucked in
            as div contents, where positioning and appearance are controlled (as
            much as possible) by css.
            >
            Much more complex than using a database. Also prone to file locking
            issues, etc. - which a database handles automatically.

            Sorry, but it sounds to me like you don't have any real database
            experience to base your comments on.

            --
            =============== ===
            Remove the "x" from my email address
            Jerry Stuckle
            JDS Computer Training Corp.
            jstucklex@attgl obal.net
            =============== ===

            Comment

            • sheldonlg

              #7
              Re: Trying to build a database driven website

              Jerry Stuckle wrote:
              doznot wrote:
              >I think database driven websites are fine for large complex sites, but
              >not so well suited to anything less than large top-dollar installations.
              >>
              >
              I have a lot of database driven sites which are small and definitely not
              "top dollar". It's valid for any time you need dynamic content.
              Totally agree.
              >With a files-based system you can search and replace recursively with
              >bash perl and sed, without having to fight with complex sql dumps and
              >updates.
              >>
              >
              Even easier to do with a SQL database.
              >
              MUCH easier to do with a database.

              >
              >....I did it with directories. Each page is actually a specially-named
              >directory containing files that are html fragments, that get sucked in
              >as div contents, where positioning and appearance are controlled (as
              >much as possible) by css.
              >>
              >
              Much more complex than using a database. Also prone to file locking
              issues, etc. - which a database handles automatically.
              Yup.
              >
              Sorry, but it sounds to me like you don't have any real database
              experience to base your comments on.
              >
              I fully agree with Jerry on all points here. Using a database for data
              driven web sites is the way to go. It is much simpler than handling files.

              Comment

              • doznot

                #8
                Re: Trying to build a database driven website

                sheldonlg wrote:
                I fully agree with Jerry on all points here. Using a database for data
                driven web sites is the way to go. It is much simpler than handling files.
                1)
                Seems to me file locking is only an issue on update. So if the site is
                administered by a single admin, this isn't an issue. If the site
                isn't administered by a single admin, then it isn't the "simple" sort
                of site I was talking about.

                2)
                content updates:
                So, let's say you have links to other websites scattered over multiple
                content blocks in multiple pages (outside the generated navigation
                system) and one or more of those links has changed.

                These links don't exist as a labeled table column, so you cannot find
                them directly with a query. You would have to query all html fragments
                in the system with multiple queries, suck those into memory and then right
                some code to search and replace the errant link. And then to update
                again, and each update would have to be custom written for each
                fragment (main display, right column, footer, whatever).
                Or you'd have to spend all day using a GUI.

                With a files based system I use recursive perl search and replace,
                which is so simple do it from the command line, rather than writing
                query, search, replace, update code into a use-once file.

                ......generatin g pages with PHP doesn't mean maintenance and changes have
                to be done that way. Bash perl sed and sometimes awk are too convenient
                to throw out the window.

                No database experience? I started with Oracle in 1995.
                That won't win any contests here, but it represents a lot more
                experience than none. I don't want to start a name calling fight.
                But I do think there is an important "small site" niche for a files
                based system.

                Comment

                • FutureShock

                  #9
                  Re: Trying to build a database driven website

                  doznot wrote:
                  sheldonlg wrote:
                  >I fully agree with Jerry on all points here. Using a database for
                  >data driven web sites is the way to go. It is much simpler than
                  >handling files.
                  >
                  1)
                  Seems to me file locking is only an issue on update. So if the site is
                  administered by a single admin, this isn't an issue. If the site
                  isn't administered by a single admin, then it isn't the "simple" sort
                  of site I was talking about.
                  >
                  2)
                  content updates:
                  So, let's say you have links to other websites scattered over multiple
                  content blocks in multiple pages (outside the generated navigation
                  system) and one or more of those links has changed.
                  >
                  These links don't exist as a labeled table column, so you cannot find
                  them directly with a query. You would have to query all html fragments
                  in the system with multiple queries, suck those into memory and then right
                  some code to search and replace the errant link. And then to update
                  again, and each update would have to be custom written for each
                  fragment (main display, right column, footer, whatever).
                  Or you'd have to spend all day using a GUI.
                  I am sort of jumping in here to give my opinion and past usage.
                  It seems to me (from experience) that if you have a Table for all links,
                  it would be simple enough to use a descriptive label in one field with
                  the link code in another.

                  Query the DB, pull in the links table and place it in an array, keys
                  being the label for each page that requires the links whether it be on a
                  navbar or separate block.

                  Then wherever you want to display the link you pull it from the array
                  that is available throughout the page.

                  Maybe I am over-simplifying this but it works for me.

                  Now I have never done file base dynamic sites, so it is hard for me to
                  compare.

                  Scotty
                  >
                  With a files based system I use recursive perl search and replace,
                  which is so simple do it from the command line, rather than writing
                  query, search, replace, update code into a use-once file.
                  >
                  .....generating pages with PHP doesn't mean maintenance and changes have
                  to be done that way. Bash perl sed and sometimes awk are too convenient
                  to throw out the window.
                  >
                  No database experience? I started with Oracle in 1995.
                  That won't win any contests here, but it represents a lot more
                  experience than none. I don't want to start a name calling fight.
                  But I do think there is an important "small site" niche for a files
                  based system.
                  >

                  Comment

                  • doznot

                    #10
                    Re: Trying to build a database driven website

                    FutureShock wrote:


                    REtable for all links.
                    Links often exist as entries in a named column somewhere,
                    as part of the navigation system.

                    But most systems also work with html fragments for the more
                    variable "display" portions of a page. If a display block
                    has a link (perhaps and editorial page referring to news stories
                    out on the net) then that link is not in any directly queryable
                    column.

                    And links to newsy items on other sites is a good example. Many
                    such links do continue to exist for a long time, but they often
                    get modified by the remote system after a certain period of time.
                    I often find myself updating links that still exist, that have
                    been changed by some remotely-located and unknown sys-admin.

                    .....and if those links are part of text block fragment, which
                    is common, then query is difficult. Recursive perl over directories
                    and files is a snap.

                    Comment

                    • Jerry Stuckle

                      #11
                      Re: Trying to build a database driven website

                      doznot wrote:
                      sheldonlg wrote:
                      >I fully agree with Jerry on all points here. Using a database for
                      >data driven web sites is the way to go. It is much simpler than
                      >handling files.
                      >
                      1)
                      Seems to me file locking is only an issue on update. So if the site is
                      administered by a single admin, this isn't an issue. If the site
                      isn't administered by a single admin, then it isn't the "simple" sort
                      of site I was talking about.
                      >
                      I don't know how many times I've heard that argument - and seen it go
                      down in flames.
                      2)
                      content updates:
                      So, let's say you have links to other websites scattered over multiple
                      content blocks in multiple pages (outside the generated navigation
                      system) and one or more of those links has changed.
                      >
                      These links don't exist as a labeled table column, so you cannot find
                      them directly with a query. You would have to query all html fragments
                      in the system with multiple queries, suck those into memory and then right
                      some code to search and replace the errant link. And then to update
                      again, and each update would have to be custom written for each
                      fragment (main display, right column, footer, whatever).
                      Or you'd have to spend all day using a GUI.
                      >
                      With a files based system I use recursive perl search and replace,
                      which is so simple do it from the command line, rather than writing
                      query, search, replace, update code into a use-once file.
                      >
                      .....generating pages with PHP doesn't mean maintenance and changes have
                      to be done that way. Bash perl sed and sometimes awk are too convenient
                      to throw out the window.
                      >
                      No database experience? I started with Oracle in 1995.
                      That won't win any contests here, but it represents a lot more
                      experience than none. I don't want to start a name calling fight.
                      But I do think there is an important "small site" niche for a files
                      based system.
                      >
                      >
                      Only since 1995? And what have you done with databases on the web - or
                      even databases in general? It doesn't sound like you've done much at all.

                      You have made it very obvious you have no idea how a database can be
                      used effectively for websites. Your own comments betray that.

                      For one thing - you equate a database with a CMS. They are two entirely
                      different things.

                      And the other errors in your statements are just too numerous to even
                      mention.

                      --
                      =============== ===
                      Remove the "x" from my email address
                      Jerry Stuckle
                      JDS Computer Training Corp.
                      jstucklex@attgl obal.net
                      =============== ===

                      Comment

                      • Jerry Stuckle

                        #12
                        Re: Trying to build a database driven website

                        doznot wrote:
                        FutureShock wrote:
                        >
                        >
                        REtable for all links.
                        Links often exist as entries in a named column somewhere,
                        as part of the navigation system.
                        >
                        But most systems also work with html fragments for the more
                        variable "display" portions of a page. If a display block
                        has a link (perhaps and editorial page referring to news stories
                        out on the net) then that link is not in any directly queryable
                        column.
                        >
                        Again, an over-generalized statement based on what you have seen from a
                        limited number of products (have you really looked at anything other
                        than Drupal?).
                        And links to newsy items on other sites is a good example. Many
                        such links do continue to exist for a long time, but they often
                        get modified by the remote system after a certain period of time.
                        I often find myself updating links that still exist, that have
                        been changed by some remotely-located and unknown sys-admin.
                        >
                        ....and if those links are part of text block fragment, which
                        is common, then query is difficult. Recursive perl over directories
                        and files is a snap.
                        >
                        It's even easier to update them in a sql database. No perl needed. One
                        simple SQL UPDATE statement does it all.


                        --
                        =============== ===
                        Remove the "x" from my email address
                        Jerry Stuckle
                        JDS Computer Training Corp.
                        jstucklex@attgl obal.net
                        =============== ===

                        Comment

                        • doznot

                          #13
                          Re: Trying to build a database driven website

                          Jerry Stuckle wrote:
                          And the other errors in your statements are just too numerous to even
                          mention.
                          >
                          OK, we'll try an experiment here. I'll assume a totally subservient
                          position. I made a terrible mistake by making representations of any
                          kind. Instead I'll as you, the acknowledged expert, a few questions:

                          1)
                          Is it true that many "database driven websites" use text blocks
                          for storing html fragments, that might, for instance, be used to
                          fill the contents of a table-td or div? (perhaps not, I'm asking, you
                          are the expert).

                          2) if the answer to question 1 is no, then there is no point in
                          reading further. That would mean I was off base and completely wrong.
                          But if so, and if those html fragments needed updating, then a query
                          would have to be written...perha ps a "if table_name.frag ment_name like
                          '%pattern%' ....then use a search and replace mechanism
                          to replace, and then update. Sure that's possible, but it's a bit
                          awkward isn't it? compared to two line recursive perl replace?

                          Please give an example, rather than vague and aggressive assertions.

                          Comment

                          • Jeff

                            #14
                            Re: Trying to build a database driven website

                            doznot wrote:
                            Jerry Stuckle wrote:
                            >And the other errors in your statements are just too numerous to even
                            >mention.
                            >>
                            >
                            OK, we'll try an experiment here. I'll assume a totally subservient
                            position. I made a terrible mistake by making representations of any
                            kind. Instead I'll as you, the acknowledged expert, a few questions:
                            >
                            1)
                            Is it true that many "database driven websites" use text blocks
                            for storing html fragments, that might, for instance, be used to
                            fill the contents of a table-td or div? (perhaps not, I'm asking, you
                            are the expert).

                            A database is a ubiquitous tool. What I think the OP wants is to
                            retrieve data about the library and display it. As such you just store
                            data in the database, you don't format it until you write the page.
                            Usually this is a complete block of html, a whole table or some such.
                            What data you bring back will be driven by the sql and generally
                            formatted one row at a time, but all rows will be formatted using the
                            same rules.

                            Now as far as CMS's, usually you are also writing large blocks of
                            html, not just a bit here and a bit there. And you know exactly where it
                            is going.
                            >
                            2) if the answer to question 1 is no, then there is no point in
                            reading further. That would mean I was off base and completely wrong.
                            But if so, and if those html fragments needed updating, then a query
                            would have to be written...perha ps a "if table_name.frag ment_name like
                            '%pattern%'
                            Such stuff is usually locked in the template. You should never have
                            to do a sitewide search and replacement. If you are making sites like
                            this you have a maintenance nightmare. Don't do that.

                            Jeff


                            .....then use a search and replace mechanism
                            to replace, and then update. Sure that's possible, but it's a bit
                            awkward isn't it? compared to two line recursive perl replace?
                            >
                            Please give an example, rather than vague and aggressive assertions.

                            Comment

                            • Jerry Stuckle

                              #15
                              Re: Trying to build a database driven website

                              doznot wrote:
                              Jerry Stuckle wrote:
                              >And the other errors in your statements are just too numerous to even
                              >mention.
                              >>
                              >
                              OK, we'll try an experiment here. I'll assume a totally subservient
                              position. I made a terrible mistake by making representations of any
                              kind. Instead I'll as you, the acknowledged expert, a few questions:
                              >
                              1)
                              Is it true that many "database driven websites" use text blocks
                              for storing html fragments, that might, for instance, be used to
                              fill the contents of a table-td or div? (perhaps not, I'm asking, you
                              are the expert).
                              >
                              Not necessarily. It means they use a database to store data of some
                              kind. It can be anything, from a complete CMS like Drupal to membership
                              details to shopping cart products - a lot of different things.
                              2) if the answer to question 1 is no, then there is no point in
                              reading further. That would mean I was off base and completely wrong.
                              But if so, and if those html fragments needed updating, then a query
                              would have to be written...perha ps a "if table_name.frag ment_name like
                              '%pattern%' ....then use a search and replace mechanism
                              to replace, and then update. Sure that's possible, but it's a bit
                              awkward isn't it? compared to two line recursive perl replace?
                              >
                              Please give an example, rather than vague and aggressive assertions.
                              >
                              That's because your first premise is 100% incorrect.

                              --
                              =============== ===
                              Remove the "x" from my email address
                              Jerry Stuckle
                              JDS Computer Training Corp.
                              jstucklex@attgl obal.net
                              =============== ===

                              Comment

                              Working...