Javascript and PHP/MySQL Question

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

    Javascript and PHP/MySQL Question

    I want to write a listbox sized to 8 rows - I want to show summaries
    in this listbox and when an item is selected, below I want to show the
    details of the summary - I can trap a javascript event for the listbox
    but can I put PHP code into the javascript event? I need to grab the
    details out of a MySQL database using PHP - so basically I'm asking
    how can I get the details to update dynamically as the user clicks on
    different listbox items?

    Thanks...

  • Richard Hockey

    #2
    Re: Javascript and PHP/MySQL Question


    "Ralph Freshour" <ralph@primemai l.com> wrote in message
    news:hor6hvo5od beas97k6ehir3f7 lhhubg29c@4ax.c om...[color=blue]
    > I want to write a listbox sized to 8 rows - I want to show summaries
    > in this listbox and when an item is selected, below I want to show the
    > details of the summary - I can trap a javascript event for the listbox
    > but can I put PHP code into the javascript event? I need to grab the
    > details out of a MySQL database using PHP - so basically I'm asking
    > how can I get the details to update dynamically as the user clicks on
    > different listbox items?[/color]

    Any php in a .php page is executed on the server BEFORE the page is sent to
    the browser, you can't fire php statements in javascript functions.

    To execute php based on what the user selects on the form, you will have to
    make a new page request from the server, with the variables in the current
    form submitted via POST or GET, or appended to the URL (= GET method).

    If you are prepared to place ALL the records in the database in javascript
    arrays, you can use these arrays to generate new from elements in the page
    using javascript alone. Obviously there are a few problems with this
    solution, mainly HTML page size and security (exposing database information
    unnecessarily).
    [color=blue]
    >
    > Thanks...
    >[/color]


    Comment

    • Jochen Daum

      #3
      Re: Javascript and PHP/MySQL Question

      Hi Ralph!
      On Tue, 15 Jul 2003 03:10:44 GMT, Ralph Freshour <ralph@primemai l.com>
      wrote:
      [color=blue]
      >I want to write a listbox sized to 8 rows - I want to show summaries
      >in this listbox and when an item is selected, below I want to show the
      >details of the summary - I can trap a javascript event for the listbox
      >but can I put PHP code into the javascript event?[/color]

      JavaScript clientside, PHP Serverside, ergo: You have to request a URL
      (x.php) with JS. Pass all needed data through URL paramaters. This
      will require a reload.
      [color=blue]
      > I need to grab the
      >details out of a MySQL database using PHP - so basically I'm asking
      >how can I get the details to update dynamically as the user clicks on
      >different listbox items?[/color]


      HTH, Jochen
      --
      Jochen Daum - CANS Ltd.
      PHP DB Edit Toolkit -- PHP scripts for building
      database editing interfaces.
      Download PHP DB Edit Toolkit for free. PHP DB Edit Toolkit is a set of PHP classes makes the generation of database edit interfaces easier and faster. The main class builds tabular and form views based on a data dictionary and takes over handling of insert/update/delete and user input.

      Comment

      Working...