基于服务器流量重定向用户

基于服务器流量重定向用户

问题描述:

I have a PHP script that finds out the number of users on each of my servers and inputs it into a MySQL database. I want the user to be redirected to the page with the least users on it, defined by the MySQL database.

How can this be done?

Thanks in advance, Callum

我有一个PHP脚本,可以找出每台服务器上的用户数并将其输入MySQL数据库 。 我希望用户被重定向到MySQL数据库定义的用户最少的页面。 p>

如何做到这一点? p>

提前致谢, Callum p> div>

You could use a query on your db that sorts on the number of users.

SELECT ServerColumn FROM Table ORDER BY NumberOfUsersColumn ASC;

That would retrieve the servers ordered by their serverload (as defined in your db).

As for the redirection part you can take a look at http://php.net/manual/en/function.header.php

And use the "Location" header.