At first what you are looking for seems to be a socket that link will find an implementation example in php , another form of solving this would be paging, bring 50 records at a time, making javascript receive data and store it in a local cache until you have all the content, but display the first 50 (using the query limit), in that site you find examples of socket server and client. You can implement later on using tcp, upd and make up stream if you want.
The socket will work on the client side and server side, the server will provide the information while the client will connect on the server to receive the data. This type of data transfer can user in TCP and UPD each has its advantages and disadvantages, The server is responsible for managing the connections a server can have from 0 to N connected clients which will limit the amount of connections at the logical level is the number of ports on each ip he is listening to and the hardware level of the equipment capacity and the link. When working with socket it is necessary to have attention on how the credentials management will be done, to control the privilege and the access. The socket is something that can be implemented on any platform today you can find socket including in javascript.
Example server socket in php:
/*********function to check new order******************/
function get_new_order()
{
$con=mysql_connect(HOST, USERNAME, PASSWORD);
mysql_select_db(DATABASE, $con);
$sql="select OrderId from customer_order where order_Status='0' "; //0 for new order
$query=mysql_query($sql,$con);
if(mysql_num_rows( $query)>0)
{
return true;
}
else return false;
}
/*************************************/
/********Socket Server*********************/
set_time_limit (0);
// Set the ip and port we will listen on
$address = '127.0.0.1';
$port = 6789;
// Create a TCP Stream socket
$sock = socket_create(AF_INET, SOCK_STREAM, 0); // 0 for SQL_TCP
// Bind the socket to an address/port
socket_bind($sock, 0, $port) or die('Could not bind to address'); //0 for localhost
// Start listening for connections
socket_listen($sock);
//loop and listen
while (true) {
/* Accept incoming requests and handle them as child processes */
$client = socket_accept($sock);
// Read the input from the client – 1024000 bytes
$input = socket_read($client, 1024000);
// Strip all white spaces from input
$output = ereg_replace("[ \t\n\r]","",$input)."/*********function to check new order******************/
function get_new_order()
{
$con=mysql_connect(HOST, USERNAME, PASSWORD);
mysql_select_db(DATABASE, $con);
$sql="select OrderId from customer_order where order_Status='0' "; //0 for new order
$query=mysql_query($sql,$con);
if(mysql_num_rows( $query)>0)
{
return true;
}
else return false;
}
/*************************************/
/********Socket Server*********************/
set_time_limit (0);
// Set the ip and port we will listen on
$address = '127.0.0.1';
$port = 6789;
// Create a TCP Stream socket
$sock = socket_create(AF_INET, SOCK_STREAM, 0); // 0 for SQL_TCP
// Bind the socket to an address/port
socket_bind($sock, 0, $port) or die('Could not bind to address'); //0 for localhost
// Start listening for connections
socket_listen($sock);
//loop and listen
while (true) {
/* Accept incoming requests and handle them as child processes */
$client = socket_accept($sock);
// Read the input from the client – 1024000 bytes
$input = socket_read($client, 1024000);
// Strip all white spaces from input
$output = ereg_replace("[ \t\n\r]","",$input)."%pre%";
$message=explode('=',$output);
if(count($message)==2)
{
if(get_new_order()) $response='NEW:1';
else $response='NEW:0';
}
else $response='NEW:0';
// Display output back to client
socket_write($client, $response);
socket_close($client);
}
// Close the master sockets
socket_close($sock);
";
$message=explode('=',$output);
if(count($message)==2)
{
if(get_new_order()) $response='NEW:1';
else $response='NEW:0';
}
else $response='NEW:0';
// Display output back to client
socket_write($client, $response);
socket_close($client);
}
// Close the master sockets
socket_close($sock);
this link will find a complete example of the socket in php and use Another interesting example can be found in the following here