Quote:
|
Originally Posted by willis30
I agree that I should just be able to do it using php but for some reason I couldnt get it to even give me and error when trying that, so I thought I would take another approach.
Care to help with the PHP code?
All I need is
ports_total - ports = ports_free
for each record that has the same building associated with it. so I can have the total number of ports free for each building
Example
Building A
Room1 has 10 ports 2 being used
Room2 has 5 ports 4 being used = Building A has 9 ports free
Building B
Room1 has 10 ports 3 being used
Room2 has 5 ports 1 being used = Building B has 11 ports free
Hope that makes since.
|
Okay, quick-and-dirty PHP code here...
<?php
$con = mysql_connect("host","user","password");
mysql_select_db("dbname");
$sql = "SELECT ports_total, ports_used FROM building WHERE building_name = 'Building A';
$result = mysql_query($sql,$con);
list($ports_total,$ports_used) = mysql_fetch_row($result);
$ports_free = $ports_total - $ports_used;
?>
That is the code needed to figure out how many ports free in MySQL. I'm sure there are other ways but that's the 60 second version.