faqts : Computers : Programming : Languages : PHP

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

13 of 30 people (43%) answered Yes
Recently 5 of 10 people (50%) answered Yes


How can I reload a sql query in the same page without opening a new page and using a submit button?

Nov 28th, 2008 11:15
healthy man, Mariusz Stankiewicz, lone wookie,

I don't know what you mean by 'reloading' a sql query in the same 
page.  As HTML dosn't talk to a SQL Server and is a client side markup 
language rather than a server side scripting language.  (I've found a 
lot of people have this problem on this forum)
What you could do, and what I have done very successfully on many 
occasions is create an invisible <IFrame> (or a <frame>/<frameset>)
which can be named your 'update frame' on the page.
When you click your Submit button, the target of the form is set to 
your 'update frame', a PHP file is loaded into the update frame and 
contains javascript which manipulates the parent frame (which is the 
frame that your original HTML page is on.
Realistically if you had a div tag for the entire page, you could 
rewrite the entire page using the frameidname.innerHTML attribute.
Or your 'update frame' could popup an alert('xxxx'); javascript box and 
tell the user their settings were updated etc, without having to reload 
the page.
There are many examples of such implementations on the net, a popular 
one is bikepoint.com.au, they use this to create a more dynamic search 
(they use <frame> tags for compatability), where you choose an option 
from a drop-down box, and another dropdown box is updated with items 
within the first drop-down box's group.
It gets quite complicated, as this moves into dynamic generation of 
javascript using PHP, and for newbies can get quite complex (if they 
don't grasp the concept of client/server languages).