Happy Codings - Programming Code Examples
Html Css Web Design Sample Codes CPlusPlus Programming Sample Codes JavaScript Programming Sample Codes C Programming Sample Codes CSharp Programming Sample Codes Java Programming Sample Codes Php Programming Sample Codes Visual Basic Programming Sample Codes

Php Programming Code Examples

Php > HTML and Php Code Examples

Constantly refresh your PHP-HTML page data

Constantly refresh your PHP-HTML page data <? ECHO "<html><head><title>Constantly refresh your page.</title></head><body>"; ECHO "Starting...<br>"; flush(); sleep(2); $i=1; while ($i < 4) { // delay ECHO "$i<br>"; // Display the counter. flush(); sleep(1); $i++; } // end // Query your database here. I am using sybase calls. if (!@sybase_Connect("DATABASENAME, "USERNAME", "PASSWORD")) { echo "<p><font color="red\">Error - Unable to connect to the sybase server. </font></p> \n"; exit; } if (!@sybase_select_db("SOMEDATABASE")) { echo "<p><font color=\"red\">Error - unable to access the specific database. </font></p> \n"; exit; } $query_get_info = "SELECT FIELDA, FIELDB, FIELDC, FIELDD FROM SOMETABLE ORDER BY FIELDA"; $rs = @sybase_query($query_get_info); // execute the query if ($rs) { // ok $nrows = 0; $nrows = @sybase_num_rows($rs); echo "<p>Found $nrows row(s). </p> \n"; if ($nrows > 0) { echo "<table border=\"1\" width=\"100%\" bordercolor=\"#000000\" bgcolor=\"#C0C0C0\" name=\"displaytable\"> \n"; $x = 0; /* display the table column headers */ echo "<tr><th bgcolor=\"#6666FF\">FIELDA</th> \n"; echo "<th bgcolor=\"#6666FF\">FIELDB</th> \n"; echo "<th bgcolor=\"#6666FF\">FIELDC</th> \n"; echo "<th bgcolor=\"#6666FF\">FIELDD</th></tr> \n"; while ($x < $nrows) { // display the information $display_row = @sybase_fetch_row($rs); echo "<tr> \n"; $display_item1 = $display_row[0]; echo "<td>$display_item1 </td> \n"; $display_item2 = $display_row[1]; echo "<td>$display_item2 </td> \n"; $display_item3 = $display_row[2]; echo "<td>$display_item3 </td> \n"; $display_item4 = $display_row[3]; echo "<td>$display_item4 </td></tr> \n"; $x++; } // end loop echo "</table><br> \n"; } // end if nrows } // end if rs ECHO "<br><b>In 5 seconds this page will refresh.</b><br>\n"; flush(); sleep(5); // Now use javascript to send the page to itself. ?> <SCRIPT LANGUAGE="JavaScript"> history.go(0) </SCRIPT> <? ECHO "</body></html>"; ?>