PHP clear content command

Jonny Two Shoes

Expert Member
Joined
Nov 13, 2006
Messages
4,542
Reaction score
17
Location
Gauteng
Simple question here if possible :)

Im running a query to mysql using a php loop. When the statement registers as true I would like it to clear the page contents and write the new info.

!!!So basically im looking for a clear content!!! php command so it can do this....searching on the web reveals nothing so far.

Im not looking to refresh the whole page or redirect it either

Any help would be appreciated :) thanks. I will gladly provide more info if necessary but this is all I seek....a simple command I do not know :p
 
Put your all your content into a div tag and just change the innerHTML property to "" that will clear everything
 
btw you'll have to do that with javascript function. Say your div id is "cont" your javascript will look like this.

<script langauge="javascript">
function clear()
{
getElementById("cont").innerHTML = "";
}
</script>

then just call clear when you need it.
 
AJAX is the way to go, but I think that kloon's way would work.
 
Last edited:
Simple question here if possible :)

Im running a query to mysql using a php loop. When the statement registers as true I would like it to clear the page contents and write the new info.

!!!So basically im looking for a clear content!!! php command so it can do this....searching on the web reveals nothing so far.

Im not looking to refresh the whole page or redirect it either

Any help would be appreciated :) thanks. I will gladly provide more info if necessary but this is all I seek....a simple command I do not know :p
If I'm reading this right then you're trying to change what is already on the screen while continuously executing the existing script? If so, then the only conceivable way of doing this is with flushing what's in the script buffer to the screen, and then following kloon's idea or going AJAX. Using this, however, would significantly increase resource usage by PHP. (see: http://www.php.net/manual/en/function.flush.php for more info but again, please heed my warning that this is going to put a strain on your server). If you mean submit information "behind the scenes" to a script and then if your conditions are met you want to "clear the screen", then AJAX is first prize.
 
Last edited:
Top
Sign up to the MyBroadband newsletter
X