(PHP) Page created in 'x' seconds with 'y' queries.
#1

Hello guys! I need some help to include this in my website but i have no idea about how to make this:
PHP код:
Page created in 'x' seconds with 'y' queries
REP++;
Reply
#2

Huh? You aren't explaining it enough.

What exactly is it you want to include on the website?
Reply
#3

At the buttom of my website i want to include a script that shows me how much time take to create the curent page and how much query!
Reply
#4

A message that shows the visitor how fast the page was loaded I guess
Reply
#5

Try to be a bit more precise
Reply
#6

PHP код:
$start time();

// code

echo "Time loaded in:" . (time()-$start); 
For querys mhm.. idk how to know how much query runned but you can do something like:

PHP код:

mysql_query
( .. );
$querys ++;

end code:

echo 
"Querys: " $querys
Reply
#7

Anyway, how is this remotely connected to pawn script?
Reply
#8

where should i put that
PHP код:
$start time(); 
?
Reply
#9

At the top of your script, put something like this:

Код:
<?php
	$pageexec_time = microtime(true);		// this will return a floating point Unix timestamp with milliseconds included
	$pageexec_queries = 0;
?>
Then for every one of your queries, increment $pageexec_query like this:
Код:
<?php
	mysqli_query($whatever);
	$pageexec_queries++;
?>
Then at the end of your script, put this bit that reports the execution time and the number of queries used:
Код:
<?php
	echo "<p>Page created in ".(microtime(true)-$pageexec_time)." seconds with $pageexec_queries queries.</p>";
?>
Reply
#10

Result: Page created in 0.00038003921508789 seconds with 1 queries.

How can i minimize the number of digits?
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)