|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
I'm building an auction site based on PHP, Javascript, MySQL and I have one question: how do you refresh parts of a page as smooth as possible? I don't want to use another frameset apart from the one that I already use.
My situation is this: I want to check in the DB if a new bid is placed by another user, if so - update the page content, but only parts of the page, since the page also contains a large picture. And ofcourse - only update the page when changes are made (example: another bidder makes a bid...). Do you understand??? I hope you do.... Please give me input - desperatly need it. |
|
#2
|
|||
|
|||
|
You could use iframes for that.. but since php is parsed each time a page is requested, it would be hard making it refresh only when a bid is made..
__________________
Best Regards, Håvard Lindset |
|
#3
|
|||
|
|||
|
OK, that is a start.
![]() The reason I do not want to refresh too often is that I have a pull-down menu with bidlevels. If it gets refreshed all the time, the user will get irritated. Any suggestions on a work-around? |
|
#4
|
|||
|
|||
|
dynamic flash? you could use it to check the database for a set interval, then if it changes, refresh the frameset
|
|
#5
|
|||
|
|||
|
Flash? Yes, why not? I have little experience of flash though...
Here is a thought: how about using a hidden frame in a frameset that scrolls through the DB for changes, refreshes by interval and posts the new data into the main window if new values occur? Could that be a soloution? |
|
#6
|
|||
|
|||
|
It worked!!
Thanks for all support. You guys are fast and furious. The use of a hidden frame that contains all the dirty scroll to the MySQL went along smoothly. When i discover a change, I update the target frame with javascript. Thanks Ben & Lidset - My Heroes |
|
#7
|
|||
|
|||
|
ahhh shucks thx
|
|
#8
|
|||
|
|||
|
Quote:
i'm also working on something where i need this kind of functionality, do you mind showing us your code? :water |
|
#9
|
|||
|
|||
|
OK. I'll show you how I have done it. Maybe it can be done in a better way. Let me just tip you to read this article, that I am reading right now:
http://developer.apple.com/internet...ipt/iframe.html It's about remote scripting with iframe. I think it can help alot of people out there. Enough talk, here comes the script: This is the main file that calls the the hidden frame. It loads the file containing the database scroll, and unloads it when finished. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <HTML> <HEAD> <LINK REL=StyleSheet HREF="<? echo $styledir ?>stylesheet.css" TYPE="text/css" TITLE="Stylesheet"> <SCRIPT LANGUAGE='JAVASCRIPT'> function Updatenadaframe() { parent.nadaright.location.href='<? echo $auctiondir ?>getdetail.php?lang=<?echo $lang ?>&obj=<?echo $obj?>&orgval=<?echo $orgval?>'; } function Backnadaframe() { parent.nadaright.location.href='<? echo $framesetdir ?>nada.php'; } // --> </SCRIPT> </HEAD> <BODY onLoad="Updatenadaframe();" onUnload="Backnadaframe();"> This is the content of the file "getdetail.php" that is loaded into the hidden frame that checks the DB for changes. The page is refreshed every 10 second and is passing parameters to itself. selectDB(); $query = mysql_query("SELECT BiddingPrice, RegUserID, UNIX_TIMESTAMP(Biddingtime) FROM Bidding WHERE ArtObjectID=".$obj." ORDER BY BiddingTime") or die("Problems with Query - checkbidchange"); mysql_close(); $newval = mysql_num_rows($query); if ($newval <> $orgval) { // Is there any change in DB? $update = 1; $orgval = $newval; } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <HTML> <HEAD> <META HTTP-EQUIV=refresh CONTENT="10;URL=getdetail.php?<? echo "obj=".$obj."&orgval=".$orgval."&lang=".$lang ?>"> <?php print "\n<SCRIPT LANGUAGE='JAVASCRIPT'>"; print "\n\nfunction updatedetail() {"; print "\nalert('"Changes are made in the database. Reloading page!"')"; print "\nparent.content.location.href='".$framesetdir."detail.php?lang=".$lang."&obj=".$obj."&pageid=".$pageid."';"; print "\n}"; print "\n</SCRIPT>"; ?> </HEAD> <?php if ($update == 1) { print "\n<BODY onLoad=\"updatedetail()\">"; } else { print "<BODY>"; } print "</BODY>"; print "</HTML>"; I hope it makes some sense to you! |
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > Refresh parts of a page |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|