PHP Abfrage alle Paar Sekunden

  • JavaScript

Es gibt 3 Antworten in diesem Thema. Der letzte Beitrag () ist von Link.

    PHP Abfrage alle Paar Sekunden

    Hallo zusammen,
    Ich bin an der Versuchung eine PHP Abfrage alle paar sekunden durchzuführen.
    Dies Funktioniert eigentlich auch schon ziemlich gut:
    load.php

    HTML-Quellcode

    1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    2. <html xmlns="http://www.w3.org/1999/xhtml">
    3. <head>
    4. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js"></script>
    5. <script>
    6. setInterval(
    7. function()
    8. {
    9. $('#content').fadeOut('slow').load('test.php').fadeIn("slow");}, 3000);
    10. </script>
    11. <title>Auto Load</title>
    12. </head>
    13. <body>
    14. <div id="content" style="background-color:#ffffcc;font-size:24px;font-family:'Georgia', Times New Roman, Times, serif;font-weight:bold;width:600px;margin:auto 10px;"> Please wait .. </div>
    15. </body>
    16. <html>

    test.php:

    PHP-Quellcode

    1. <?php
    2. ini_set('display_errors', true);
    3. include('db_connect_i.inc.php');
    4. $erledigt = 1;
    5. $sql = "SELECT *
    6. FROM gestempelt" ;
    7. $erg = $db->query ($sql) or die ("Fehlermeldung=".$db->error());
    8. while(($row = $erg->fetch_assoc()) !== Null){
    9. $a=$row["id"];
    10. $b=$row["uid"];
    11. $c=$row["zeit"];
    12. $d=$row["neu"];
    13. }
    14. if ($d == 0){
    15. $stmt = $db->prepare("UPDATE gestempelt SET neu = ? WHERE id = ?");
    16. $stmt->bind_param('si',$erledigt,
    17. $a
    18. );
    19. $stmt->execute();
    20. $stmt->close();
    21. Header('Location: index.php?uid=' . $b . '');
    22. }
    23. ?>


    Nur ist das problem, dass die seite index.php nicht als neue Seite geöffnet wird sonder nur in der Seite seite load.php "included" wird :S

    Also eigentlich möchte ich das eine neue Seite geladen wird :)
    Wie genau soll die Seite neu geladen werden? Soll sie sich als neuer Tab oder als neues Fenster aufmachen oder einfach banalerweise im selben Fenster statt der vorherigen Seite die test.php anzeigen?
    Ich würde es an deiner Stelle mal mit window.location = test.php probieren.
    In general (across programming languages), a pointer is a number that represents a physical location in memory. A nullpointer is (almost always) one that points to 0, and is widely recognized as "not pointing to anything". Since systems have different amounts of supported memory, it doesn't always take the same number of bytes to hold that number, so we call a "native size integer" one that can hold a pointer on any particular system. - Sam Harwell
    Hmm da komm ich nicht ganz nach, da es um den link:

    Quellcode

    1. Header('Location: index.php?uid=' . $b . '');


    Dies liegt ja im php file "test.php"

    kannst du mir dies genauer erklären?

    es soll ganz banal im selben Fenter geöffnet werden.