Rob W. wrote:
I still have not yet found anybody to help me with this. All the code
that people have given me has not worked at all. I still get no output.
So to add a little more to this, I'm gonna define how the database looks.
----------------------------------
| switchid | switchport |
----------------------------------
| 1 | 1 |
| 1 | 2 |
| 1 | 3 |
| 1 | 4 |
| 1 | 7 |
| 1 | 10 |
----------------------------------
I'm sure the code that people have posted will work if you do more than
just copy/paste it and try to understand it and match it to what you want.
$switch_ports_taken = array();
$query = "select switchport from table where switchid=1";
$result = mysql_query($query);
if (!$result) die("error: " . mysql_error());
while($row = mysql_fetch_assoc($result)) {
array_push($switch_ports_taken, $row['switchport']);
}
echo "Got these ports: " . print_r($switch_ports_taken, true) . "<br/>";
$all_ports = range(1,24);
$unused_ports = array_diff($all_ports, $switch_ports_taken);
echo "Unused ports: " . print_r($unused_ports, true) . "<br/>";
If that doesn't work tell us what doesn't work and don't make us guess
what's going on.
--
Postgresql & php tutorials
http://www.designmagick.com/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php