PHP - 2 decima places & How to reload my secure page

Asked By Olusegun A. on 30-Oct-09 03:15 AM
Hello There,

How do i put full-stop (.) after second figure from behind? ie if i have 123456 in my database and i want it to echo as 1234.56

Secondly, am designing a shopping website. I want the pages to be refreshed after every 5 minutes of usage that is, after the customer might have login to his account and the page is opened for 5 minutes without any operation on the page, i want the page to redirect the customers to login page if the customer now try to use the page after 5 minute o idleness of the page and when he might have login again he should be directed to the page where he was.


See this to format number - Sagar P replied to Olusegun A. on 30-Oct-09 03:40 AM

To format numbers, you will have to switch from an ECHO command to a PRINTF command.

$first_number = 10;
$second_number = 3;
$div_value = $first_number / $second_number;
printf ("%01.2f", $div_value);
echo "<br />";
$total_sum = $first_number + $second_number;
printf ("%01.2f", $total_sum);


redirect or Refresh page - mv ark replied to Olusegun A. on 30-Oct-09 05:31 AM

Try using this snippet in all your pages that need the redirect or Refresh functionality  -

var idle = 0;
function redirectOrRefresh(){
if (idle)
window.location = "login.php?page=" + location.href;

window.onload = function() {

You can choose to place this in a header file that you can call in all pages.