Marine1969
IS-IT--Management
I am trying to use an inner join to display a report but am not getting any results. I have the sql in workbench and the results show up there so I'm not sure why I am not getting it through the php. Below is the code that I am echoing to the screen. $d1 and $d2 are beginning and ending dates. Below that is the results.... What am I doing wrong here?
Select invoices.idinvoice, invoices.invoice, invoices.idcst, invoices.ddate, invoices.chargec, invoices.chargeb, invoices.fuel, invoices.billingtotal, customers.name, customers.city From invoices Inner Join customers On invoices.idcst = customers.idcst Where ddate Between '2018-06-25' And '2018-07-01' And idclient = 2 Order By invoices.ddate, customers.name
PHP:
$str=$conn->prepare("Select invoices.idinvoice, invoices.invoice, invoices.idcst, invoices.ddate, invoices.chargec, invoices.chargeb, invoices.fuel, invoices.billingtotal, customers.name, customers.city "
. "From invoices Inner Join customers On invoices.idcst = customers.idcst "
. "Where ddate Between '" . $d1 . "' And '" . $d2 . "' And idclient = " . $row['idclient'] . " "
. "Order By invoices.ddate, customers.name");
Select invoices.idinvoice, invoices.invoice, invoices.idcst, invoices.ddate, invoices.chargec, invoices.chargeb, invoices.fuel, invoices.billingtotal, customers.name, customers.city From invoices Inner Join customers On invoices.idcst = customers.idcst Where ddate Between '2018-06-25' And '2018-07-01' And idclient = 2 Order By invoices.ddate, customers.name