Hi
Please, I want to get information from 3 tables (Calls,Estructure, rates) These are the tables:
calls
Id IdCall Type Ext Date Hour Elapse Number
53 4 S 236 03/15 08:29 17 2050199
54 4 S 236 03/15 08:31 12 5070399
55 1 S 220 03/16 08:31 5 005938619
56 5 E 204 03/16 08:32 1
57 2 S 210 03/16 08:33 1 025419223
58 2 S 210 03/16 08:39 1 3412132
59 5 E 0 03/16 08:40 1
estructure
Ext Name Deparment
0 Ope. Admin
204 HelpDesk IT
210 IT IT
220 Ext220 Ope
236 Modem Ope
223 HelpDesk IT
rates
IdCall Number Carrier Rate
1 00 Long Dist 30
2 02 National 15
4 2 Local 10
4 3 Local 10
4 5 Local 10
5 Null Incoming 0
The table calls have information coming from a PBX (Incoming calls are E type and outgoing are S type), What I want It's to bill the calls according to tables rates and estructure, for example for the first row in table calls:
Type Ext Name Date Hour Elapse Cost Number Carrier
S 236 Modem 03/15 08:29 17 170 2050199 Local
I want to relate calls table with estructure to get name and department, And relate calls table with rates to get the cost, carrier etc.
I want to multiply Elapse from calls table and rate from rates table to get the cost (cost=Elapse*cost), How can I put the registers from a table in variables, for manipulating, for example to Multiply elapse and rate to get the cost.
This is my program:
<?php
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("my_db", $con);
// Construct our join query
$query = "SELECT calls.IdCall, calls.Ext, calls.number, calls.elapse, estructure.name, estructure.deparment, rates.Idcall, rates.carrier, rates.rate,".
"FROM calls , estructure , rates ".
"WHERE calls.Ext = estructure.Ext and calls.IdCall = rates.IdCall";
$result = mysql_query($query) or die(mysql_error());
// Print out the contents of each row into a table
while($row = mysql_fetch_array($result)){
echo $row['Ext']. " - ". $row['name']. " - ". $row['deparment']. " - ". $row['number']. " - ". $row['carrier']. " - ". $row['cost'];
echo "<br />";
}
?>
The program works, but When an Ext appears in more than one register in table calls the report shows me duplicated lines.
Any idea?
Please, I want to get information from 3 tables (Calls,Estructure, rates) These are the tables:
calls
Id IdCall Type Ext Date Hour Elapse Number
53 4 S 236 03/15 08:29 17 2050199
54 4 S 236 03/15 08:31 12 5070399
55 1 S 220 03/16 08:31 5 005938619
56 5 E 204 03/16 08:32 1
57 2 S 210 03/16 08:33 1 025419223
58 2 S 210 03/16 08:39 1 3412132
59 5 E 0 03/16 08:40 1
estructure
Ext Name Deparment
0 Ope. Admin
204 HelpDesk IT
210 IT IT
220 Ext220 Ope
236 Modem Ope
223 HelpDesk IT
rates
IdCall Number Carrier Rate
1 00 Long Dist 30
2 02 National 15
4 2 Local 10
4 3 Local 10
4 5 Local 10
5 Null Incoming 0
The table calls have information coming from a PBX (Incoming calls are E type and outgoing are S type), What I want It's to bill the calls according to tables rates and estructure, for example for the first row in table calls:
Type Ext Name Date Hour Elapse Cost Number Carrier
S 236 Modem 03/15 08:29 17 170 2050199 Local
I want to relate calls table with estructure to get name and department, And relate calls table with rates to get the cost, carrier etc.
I want to multiply Elapse from calls table and rate from rates table to get the cost (cost=Elapse*cost), How can I put the registers from a table in variables, for manipulating, for example to Multiply elapse and rate to get the cost.
This is my program:
<?php
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("my_db", $con);
// Construct our join query
$query = "SELECT calls.IdCall, calls.Ext, calls.number, calls.elapse, estructure.name, estructure.deparment, rates.Idcall, rates.carrier, rates.rate,".
"FROM calls , estructure , rates ".
"WHERE calls.Ext = estructure.Ext and calls.IdCall = rates.IdCall";
$result = mysql_query($query) or die(mysql_error());
// Print out the contents of each row into a table
while($row = mysql_fetch_array($result)){
echo $row['Ext']. " - ". $row['name']. " - ". $row['deparment']. " - ". $row['number']. " - ". $row['carrier']. " - ". $row['cost'];
echo "<br />";
}
?>
The program works, but When an Ext appears in more than one register in table calls the report shows me duplicated lines.
Any idea?