dynamically populate drop-down list and dynamically include html file

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

    dynamically populate drop-down list and dynamically include html file

    We have a drop down list on a PHP page, with several product names, and
    when people click one item, we will refresh the same page with the
    product name as parameter, and in turn we want to include a HTML file
    into the content area of the same page.

    I know it is recommended to put everything into database, but we want
    the web site to be very "portable", so the drop-downlist and the
    content should both in text files.

    Let's say the drop-down list will be poplulated from the product.txt
    file, and there will be a file for each corresponding item in the
    drop-down list. From the user point of view, if he wants to add a new
    product, he will just need to open the product.txt file, and add a new
    line with the product name, "Laptop", then add a new text file named
    "laptop" in the same folder which contains the HTML fragment to be
    included in the content area.

    What is the easiest way to do this?

  • Jerry Stuckle

    #2
    Re: dynamically populate drop-down list and dynamically include htmlfile

    Yi Chen wrote:
    We have a drop down list on a PHP page, with several product names, and
    when people click one item, we will refresh the same page with the
    product name as parameter, and in turn we want to include a HTML file
    into the content area of the same page.
    >
    I know it is recommended to put everything into database, but we want
    the web site to be very "portable", so the drop-downlist and the
    content should both in text files.
    >
    Let's say the drop-down list will be poplulated from the product.txt
    file, and there will be a file for each corresponding item in the
    drop-down list. From the user point of view, if he wants to add a new
    product, he will just need to open the product.txt file, and add a new
    line with the product name, "Laptop", then add a new text file named
    "laptop" in the same folder which contains the HTML fragment to be
    included in the content area.
    >
    What is the easiest way to do this?
    >
    I'd use a database. The vast majority of sites use MySQL for a
    database, but if you want it to be portable you can use the PEAR::MDB2
    package. It's portable to many different databases.

    You could do it with a flat file, but it will make your job a lot harder
    (and the data much more prone to errors).
    --
    =============== ===
    Remove the "x" from my email address
    Jerry Stuckle
    JDS Computer Training Corp.
    jstucklex@attgl obal.net
    =============== ===

    Comment

    • IchBin

      #3
      Re: dynamically populate drop-down list and dynamically include htmlfile

      Jerry Stuckle wrote:
      Yi Chen wrote:
      >We have a drop down list on a PHP page, with several product names, and
      >when people click one item, we will refresh the same page with the
      >product name as parameter, and in turn we want to include a HTML file
      >into the content area of the same page.
      >>
      >I know it is recommended to put everything into database, but we want
      >the web site to be very "portable", so the drop-downlist and the
      >content should both in text files.
      >>
      >Let's say the drop-down list will be poplulated from the product.txt
      >file, and there will be a file for each corresponding item in the
      >drop-down list. From the user point of view, if he wants to add a new
      >product, he will just need to open the product.txt file, and add a new
      >line with the product name, "Laptop", then add a new text file named
      >"laptop" in the same folder which contains the HTML fragment to be
      >included in the content area.
      >What is the easiest way to do this?
      >>
      >
      I'd use a database. The vast majority of sites use MySQL for a
      database, but if you want it to be portable you can use the PEAR::MDB2
      package. It's portable to many different databases.
      >
      You could do it with a flat file, but it will make your job a lot harder
      (and the data much more prone to errors).
      If you opt to use PEAR::MDB2 you may want to look at PEAR HTML_QuickForm
      for loading the dropdown. You can do it using three lines of code. Here
      I am loading a Category dropdown. Take a peek at the Docs.


      // Create a HTML <Selectand define the DB column and label
      $s =& $form->createElement( 'select','u_cat egory','Categor y:' );
      //
      // Load the <Selectfrom DB with SQL select
      $s->loadQuery($MDB 2, $category_dropd own_select);
      //
      // Add the <Selectobject to the HTML Form
      $form->addElement($s) ;

      --
      Thanks in Advance...
      IchBin, Pocono Lake, Pa, USA http://weconsultants.phpnet.us
      'If there is one, Knowledge is the "Fountain of Youth"'
      -William E. Taylor, Regular Guy (1952-)

      Comment

      • bobmct

        #4
        Re: dynamically populate drop-down list and dynamically include html file

        Yi Chen wrote:
        We have a drop down list on a PHP page, with several product names, and
        when people click one item, we will refresh the same page with the
        product name as parameter, and in turn we want to include a HTML file
        into the content area of the same page.
        >
        I know it is recommended to put everything into database, but we want
        the web site to be very "portable", so the drop-downlist and the
        content should both in text files.
        >
        Let's say the drop-down list will be poplulated from the product.txt
        file, and there will be a file for each corresponding item in the
        drop-down list. From the user point of view, if he wants to add a new
        product, he will just need to open the product.txt file, and add a new
        line with the product name, "Laptop", then add a new text file named
        "laptop" in the same folder which contains the HTML fragment to be
        included in the content area.
        >
        What is the easiest way to do this?
        By far the easiest and slickest way to accomplish this is with AJAX. Search
        the javascript group for ajax or better yet, search for mybic.php and
        download and install. It is a function for using ajax and allows you to
        access your host and receive content then dynamically populate virtually
        anything (I like to populate drop down lists)... all without the user
        having to click anything and without having to refresh the screen.

        Good luck.

        Comment

        Working...