Hide and Show message

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

    #1

    Hide and Show message

    Hi there

    I'm not so hot on JavaScript so not sure if this can be done.
    I have a PHP page that runs a MySQl query, while these queries
    are running I would like to show a message saying 'Processing.... '
    once the query has finished running the message disappears.

    I was thinking of showing then hiding a layer, but I don't know
    how to say, show this message at a set point eg below the
    select box on the screen


    Brian



  • Razzbar

    #2
    Re: Hide and Show message



    Brian wrote:[color=blue]
    > Hi there
    >
    > I'm not so hot on JavaScript so not sure if this can be done.
    > I have a PHP page that runs a MySQl query, while these queries
    > are running I would like to show a message saying 'Processing.... '
    > once the query has finished running the message disappears.[/color]

    Generally, the page won't be sent to the browser until all the
    processing is finished anyway. You can try to send something to
    the browser before the processing begins, using ob_flush() and
    flush(), but there's no guarantee that it will appear on the
    browser because of buffering that takes place both at the server
    and the browser.

    [color=blue]
    > I was thinking of showing then hiding a layer, but I don't know
    > how to say, show this message at a set point eg below the
    > select box on the screen[/color]

    There are a couple ways you could do that. You could either set
    the style property to display:none and display:block to hide or
    show the element that carries the message. Or you could just
    change the innerHTML property of the element.

    But neither will work in your case, because the PHP script that
    generates the page probably won't appear until it's all finished
    processing.

    Comment

    • Jc

      #3
      Re: Hide and Show message

      The root problem may very well be inefficient SQL query usage, which if
      fixed, would negate the need for a progress message altogether. You may
      want to spend some time optimizing your queries, or eliminating queries
      completely - assuming you haven't done so already.

      For example, rather than running a query that returns say, 1000 records
      from table A, and then running a second query for each of those 1000
      records against table B, it can be a lot more efficient to grab the
      entire applicable contents of the tables you are working with via two
      simple queries (select * from ). The resulting recordsets would then be
      iterated through and the data stored in internal data structures within
      PHP, and then operations on those native objects can be used to do your
      data processing rather than making thousands of "expensive" calls to a
      database.

      You can even take this a step farther, and cache these local
      representations of your data for a period of time, allowing the code to
      process multiple requests without having to go out to the database each
      time.

      Granted, you have to write more code, but you are also avoiding taxing
      your database and making your user(s) wait (not to mention increasing
      the scalability of your application).


      Brian wrote:[color=blue]
      > Hi there
      >
      > I'm not so hot on JavaScript so not sure if this can be done.
      > I have a PHP page that runs a MySQl query, while these queries
      > are running I would like to show a message saying 'Processing.... '
      > once the query has finished running the message disappears.
      >
      > I was thinking of showing then hiding a layer, but I don't know
      > how to say, show this message at a set point eg below the
      > select box on the screen
      >
      >
      > Brian[/color]

      Comment

      • Razzbar

        #4
        Re: Hide and Show message



        Jc wrote:[color=blue]
        > The root problem may very well be inefficient SQL query usage, which if
        > fixed, would negate the need for a progress message altogether.[/color]

        No, it would not. Whenever a program has to communicate with another
        one
        over a network, there is the possibility that the other one is out to
        lunch, on vacation, under attack, etc...

        It's generally good practice to display a "busy" message whenever an
        operation could take some time, and to have a timeout function as well.


        This isn't the easiest thing to do when a page submits a form with
        itself
        as the target, of course. But...
        [color=blue]
        > You may
        > want to spend some time optimizing your queries, or eliminating queries
        > completely - assuming you haven't done so already.[/color]

        Sure. Of course. We should optimize everything always. And plan for
        less
        than optimum results.

        Comment

        • Brian

          #5
          Re: Hide and Show message

          Hi Guys

          I have done it by showing and hiding a layer. The trouble is not
          the statement, that is fine, the trouble is it has to look though
          40,000 record and do a load of calculation, that's what's slowing it
          down.

          When the form is submitted (back to it's self ) I top of the page loads
          OK, then it starts the SQl stuff, just before it I show the layer, once
          it's finished it hides it.

          Brian




          "Razzbar" <glakk@potatora dio.f2s.com> wrote in message
          news:1118774323 .910856.292310@ g44g2000cwa.goo glegroups.com.. .[color=blue]
          >
          >
          > Jc wrote:[color=green]
          >> The root problem may very well be inefficient SQL query usage, which if
          >> fixed, would negate the need for a progress message altogether.[/color]
          >
          > No, it would not. Whenever a program has to communicate with another
          > one
          > over a network, there is the possibility that the other one is out to
          > lunch, on vacation, under attack, etc...
          >
          > It's generally good practice to display a "busy" message whenever an
          > operation could take some time, and to have a timeout function as well.
          >
          >
          > This isn't the easiest thing to do when a page submits a form with
          > itself
          > as the target, of course. But...
          >[color=green]
          >> You may
          >> want to spend some time optimizing your queries, or eliminating queries
          >> completely - assuming you haven't done so already.[/color]
          >
          > Sure. Of course. We should optimize everything always. And plan for
          > less
          > than optimum results.
          >[/color]


          Comment

          Working...