Re: Re: Ok next php problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Rob W. wrote:
No, but ok here goes the whole thing and sorry if I didnt explain this to everyone before.

I am trying to duplicate a program that keep's track of server information, switch ports, apc ports ect ect...

In the one column is switchports

This lists a total of 24 or 48 or how many ever ports are on that switch.

With in there is numbers like this for example:

1
2
3
4
5
6
7
10
11
12
13
14
15

ect... Hopefully that help's so far.

As far as listing the numbers is ok, I can pull it from the db and list all the numbers just fine in numerical order as they are listed.

My problem is inside this script, when a new server is added, it pulls the information from the database and finds an empty number, which is why, though the whole list of 1 though 24 i need to get the information of the missing numbers. These missing numbers HAFT to be dynamic and can not be hard coded in because servers are always moved around and changed and added. I hope this information was helpful for those of you trying to help solve my problem.

My answer will help you then. You know how many you have (24 or 48), so:

$good_list = range(1, 48);
$taken_list = array();

$query = "SELECT port FROM table";
$result = mysql_query($query);
while($row = mysql_fetch_assoc($result)) {
  array_push($taken_list, $row['port']);
}

$not_taken = array_diff($good_list, $taken_list);


--
Postgresql & php tutorials
http://www.designmagick.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux