Callum Whyte
Callum Whyte

Reputation: 2429

Redirect Users Based on Server Traffic

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

Upvotes: 0

Views: 147

Answers (1)

CoolMcGrrr
CoolMcGrrr

Reputation: 774

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.

Upvotes: 1

Related Questions