• 0

Refreshing DIV in PHP


Question

11 answers to this question

Recommended Posts

  • 0

Having your page refresh has nothing to do with PHP. Can you elaborate on exactly what you're trying to do? You're including a file which could have anything in it, and the result will be your coded HTML plus whatever is in php/forumstats.php in your browser. Are you wanting to have your page refresh after a certain number of seconds? Are you wanting to content to automatically update without the page actually refreshing?

  • 0

The include just pulls out stats from a DB. such as last post etc. Obviously this updates when you refresh the page.

Im not saying it has anything to do with PHP, its either JS or ajax. But i need a script to either refresh a div or a php include.

I'd like to be able to set it to auto refresh just this div (which in turn reloads the include) every X seconds.

Can talk on MSN if you are willing to help? I'dd add you if you ok it!

  • 0
  illmonkey said:
The include just pulls out stats from a DB. such as last post etc. Obviously this updates when you refresh the page.

Im not saying it has anything to do with PHP, its either JS or ajax. But i need a script to either refresh a div or a php include.

You can't refresh a DIV, nor any other HTML element "on the fly" without any scripting.

You CAN refresh the entire page using a script or the meta refresh element.

You can also have a script get data from a server and have it write this data to the page at set intervals. This is also known as AJAX.

  • 0
  raskren said:
You can't refresh a DIV, nor any other HTML element "on the fly" without any scripting.

You CAN refresh the entire page using a script or the meta refresh element.

You can also have a script get data from a server and have it write this data to the page at set intervals. This is also known as AJAX.

Fine, im incorrect with the process.

Include outputs figures. I would like said figures to refresh on the page without loading the whole lot! If that is ajax, then let me use ajax. Just tell me how! lol

  • 0

You could use an iframe, put the src to your php page. Have the php page do a meta refresh. In the end you will have an iframe that will refresh the php page. Make sense, the current solution is only setup to meta refresh in IE.

Embed this in the page where you want to show the contents of the php page:

<iframe width="468" height="60" src="https://clients.seadoosportboats.com/vendors.php" frameborder="0" scrolling="no" marginheight="0" marginwidth="0"></iframe>

Make your php page look something like this:

<html>
<head>
<script language="javascript">
<!--
if (navigator.appName == "Microsoft Internet Explorer")
document.write('<METAP-EQUIV=Refresh CONTENT="30" /&gt;');
--&gt;
&lt;/script&gt; 
&lt;/head&gt;
&lt;body bgcolor="#FFFFFF" marginheight="0" marginwidth="0" topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0"&gt;
&lt;table border="0" cellpadding="0" cellspacing="0" align="center"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;a href='http://clients.seadoosportboats.com/clientserver/www/delivery/ck.php?n=a770acb9&cb=1002' target='_blank'&gt;
&lt;img src='http://clients.seadoosportboats.com/clientserver/www/delivery/avw.php?campaignid=5&source=SeaDooSportBoats.com&cb=1002&n=a770acb9' border='0' alt='Salt-Away Products, Inc.' title='Salt-Away Products, Inc.' /&gt;&lt;/a&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/body&gt;
&lt;/html&gt;

I have coded it so it will only meta refresh with IE, you could change this if you would like. See if this helps at all. :)

  • 0

Just search for a simple ajax script. This is the whole point of AJAX, refresh only the part of the page you wish to refresh. The timer can be done in the javascript to launch the request to the server, but worry about that part last. If you don't want to get your hands dirty with some simple ajax, there are plenty of ajax frameworks you could use instead.

  • 0
  rson451 said:
Just search for a simple ajax script. This is the whole point of AJAX, refresh only the part of the page you wish to refresh. The timer can be done in the javascript to launch the request to the server, but worry about that part last. If you don't want to get your hands dirty with some simple ajax, there are plenty of ajax frameworks you could use instead.

I'd love to see one then!

I've tried loads of ajax guides and prebuild code and none of them work.

So if you have one that does, please let me know

  • 0
  illmonkey said:
Thanks! I'll try it now.

What about other browsers too!

Like I said you should be able to modify it, you just need to do a little reading on your own. Read about navigator.appName.

&lt;script language="javascript"&gt;
&lt;!--
if (navigator.appName == "Microsoft Internet Explorer")
document.write('<METAP-EQUIV=Refresh CONTENT="30" /&gt;');
--&gt;
&lt;/script&gt;

Let us know what approach you take and if you get it working.

  • 0

Check out a library like jQuery, which I use extensively at work and for my own sites. Read up on the library's documentation. If you don't know javascript, now would be a good time to learn, it's quite an easy language to pick up.

In jQuery, it's simple as using this code on your main page.

&lt;head&gt;
  &lt;script type="text/javascript" language="javascript" src="js/jQuery.js"></script>lt;script type="text/javascript" language="javascript"&gt;
	function updateForumStats() {
	  $.get("php/forumstats.php", function(data) {
		$("#forumstats").html(data);
		  });
   	  window.setTimeout("updateForumStats();", 10000);
	}

	$(document).ready(function() {
	  updateForumStats();
	});
  &lt;/script&gt;
&lt;/head&gt;

You can play with the "10000" (the 2nd argument of the window.setTimeout() function, which is in milliseconds) to have it refresh as often as you'd like.

Edited by jimbo11883
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • True they were Inspiron models and Dell's SupportAssist has a long history of security vulnerabilities. I also had problems with Dell System Detect and the Dell Software Update utility program. It was all way too much trouble. So I just removed all of them and manually did updates from their website but that was also a pain. Overall, the Inspiron's were decent enough until one became unusable for Windows after a malware attack. I Installed Ubuntu on it and used it with Ubuntu for several months before giving it away.
    • You can now turn 2D images into 3D objects with Copilot's new feature by Taras Buria Copilot Labs, a section with various experimental features in Microsoft's AI assistant, received a new feature called Copilot 3D. With this feature, Copilot lets you transform 2D images into usable 3D objects. Microsoft wants to simplify the process of creating 3D models, giving users a useful tool that has no steep learning curves and does not require installing complicated software. With Copilot 3D, users can transform images into 3D models for later use in game development, animations, 3D printing, design, AR or VR content, art projects, and more. Additionally, users can browse a library of various 3D objects and scenes for inspiration, which sounds awfully familiar to the now-deceased Paint 3D and its content marketplace. Copilot 3D is a one-click solution. All you need is to upload a picture (PNG or JPG, less than 10MB) and wait for Copilot to do its job. Unfortunately, Copilot cannot generate 3D objects from text prompts, at least for now, as Microsoft says in the announcement article. Copilot 3D is available for free globally to a subset of Copilot users, but you need a Microsoft Account to access it from the browser. Once your object is generated, you can download it in GLB format so that you can later modify it in any compatible 3D viewer, editor, or game engine. Microsoft also adds that all creations are stored for 28 days, and the company does not use the uploaded images for model training or personalization. In case you missed it, Microsoft recently introduced another Copilot Labs feature, which gives the assistant a physical appearance with physical expressions and emotions for a more natural conversation in Voice Mode. Also, Microsoft launched Gaming Copilot in Game Bar so that AI can see what is going on on the screen and give you tips, suggestions, and other useful information.
    • Shou Zi Chew was Xiaomi's CFO for five years and was with them when they were blacklisted by the first Trump administration. Xiaomi was subsequently removed from the blacklist by the Biden administration. Sen. Cotton was also a Senator when Xiaomi was blacklisted though I don't recall if he was influential in bringing about the blacklisting.
  • Recent Achievements

    • One Month Later
      Jaclidio hoy earned a badge
      One Month Later
    • Week One Done
      Yawdee earned a badge
      Week One Done
    • Week One Done
      eugwalker earned a badge
      Week One Done
    • First Post
      Ben Gross earned a badge
      First Post
    • One Month Later
      chiptuning earned a badge
      One Month Later
  • Popular Contributors

    1. 1
      +primortal
      621
    2. 2
      +FloatingFatMan
      173
    3. 3
      ATLien_0
      138
    4. 4
      Xenon
      114
    5. 5
      wakjak
      108
  • Tell a friend

    Love Neowin? Tell a friend!