0

I found my difficulty (sorry, I'm no php coder but learning by doing ;) ) in the first piece code the loop is started. It pulls all the correct data and fills in the correct fields in a table. during this loop I need to pull per line in the table extra data by php call to an api.

This is where I re-use the InvoiceCode in the second piece of code. this gives also all the correct data in the array $response . From what i understand is that I should start here a second loop, which loops thru the array $response and fills in the $row['PaymentURL'] but this ends up in an error 500

I pull data out of a db with php script and put it in some tables

echo "</table><br><th> outstanding invoices</th> <br>";
$result = mysqli_query($con,"SELECT SOME_QUERY ");
while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['Username'] . "</td>";
echo "<td>" . $row['CompanyName'] . "</td>";
echo "<td>" . $row['InvoiceCode'] . "</td>";
echo "<td>" . $row['SentDate'] . "</td>";
echo "<td>" . $row['Status'] . "</td>";
echo "<td>" . $row['AmountIncl'] . "</td>";
echo "<td>" . $row['AmountPaid'] . "</td>";

I reuse $row['InvoiceCode'] to get some api data which is not in a db field.

$api = new API();
$invoiceParams = array(
            'InvoiceCode'   => $row['InvoiceCode']);
$response = $api->sendRequest('invoice', 'show', $invoiceParams);
print_r_pre($response);

In the output of $response there is output of PaymentURL. This I wish to capture in separate table

Example output

[invoice] => Array ( [Identifier] => 17 [InvoiceCode] => F0005 [Debtor] => 14 [DebtorCode] => DB0005 [Status] => 2 [SubStatus] => [Date] => 2018-07-12 [Term] => 14 [PayBefore] => 2018-07-26 [PaymentURL] => https://www.xxx.nl/paymenturl?889430?key?whatever?invoices:dfsdfwe93

At this moment my tablefield is filled with the word array instead of the PaymentURL.

Who can help me a bit further

  • 1
    Iterate over array and `echo` each field. – u_mulder Oct 06 '18 at 11:45
  • 1
    It's not really clear what you want to achieve, please take a minute to read [How to create a Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve) and consider edit your question. – Johan Oct 06 '18 at 11:46
  • 1
    you've miss the part of the code where you store `[PaymentURL]` in the db – DaFois Oct 06 '18 at 11:50
  • @u_mulder : you mean like here? https://stackoverflow.com/questions/4414623/loop-through-an-array-php – Bankey Biharidassa Oct 06 '18 at 11:59

0 Answers0