Design Question in PHP

Discussion in 'PHP' started by gvivek99, Mar 11, 2007.

  1. #1
    Hi Friends,
    I am new to PHP world. I have 5 pages which is more data intensive. I need to open and do operation in mysql database. I am opening and closing db in all pages.

    Can you suggest me a good design so that I do not need to write my db script every time


    Thx
     
    gvivek99, Mar 11, 2007 IP
  2. nanome

    nanome Peon

    Messages:
    8
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Sorry mate, your question wasn't very clear.

    What do you mean when you say you "have 5 pages" ?
    5 php scripts or maybe 5 html pages generated from php?

    To save yourself writing the db script every time, just put into a function and use that.
     
    nanome, Mar 11, 2007 IP
  3. Robert Plank

    Robert Plank Peon

    Messages:
    55
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Look up includes in the PHP manual. You can put your database code in one file, like db.php, and then have you other scripts include it, like:

    include("db.php");
    PHP:
     
    Robert Plank, Mar 11, 2007 IP
  4. srobona

    srobona Active Member

    Messages:
    577
    Likes Received:
    57
    Best Answers:
    0
    Trophy Points:
    88
    #4
    That's a very nice and effective suggesstion from robert plank. It will 100% successfully work.
     
    srobona, Mar 11, 2007 IP
  5. jitesh

    jitesh Peon

    Messages:
    81
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Generate a PHP files which contains database connections and then include that file in all your 5 pages.
     
    jitesh, Mar 13, 2007 IP