How to handle elements of an array individually?

Asked

Viewed 100 times

1

Greetings gentlemen,

I’m trying to design a portal where my clients can view their invoices, statements and bills. As you can see it’s all very amateur, but it’s almost ready to do what I need. Below follows the PHP code and how I did so that the "invoice" information of the database could turn a link (for viewing and downloading a file). The problem arises when I try to do the same with the object "reserve".

As there will always be multiple bookings per invoice, Mysql extracts this information as a line. I need to manipulate every number present in it, but everything I try just affects my line as a whole.

Here is a link to a previous question explaining the use of group_concat in this case: https://stackoverflow.com/questions/38549723/how-to-group-data-with-mysql-php

Page result:

inserir a descrição da imagem aqui

<?php
$mysqli = NEW MySQLi('localhost','root','','server');

$sqlFatura = $mysqli->query("SELECT login as NOME,fatura AS  
Fatura, Emissao, Vcto, group_concat(reserva) AS RESERVAS
FROM usuarios INNER JOIN faturas,anexos WHERE 
usuarios.ID=IDlogin AND faturas.ID=IDfatura AND login='". 
mysql_real_escape_string($_SESSION['login'])."' GROUP BY fatura");


if($sqlFatura->num_rows > 0){
    while($rows = $sqlFatura->fetch_assoc()){
        $fatura = $rows['Fatura'];
        $loc = $fatura .".pdf";
        $stur = $rows['RESERVAS'];
        $emissao = $rows['Emissao'];
        $vcto = $rows['Vcto'];

    echo "<p> Fatura $fatura Emitida dia $emissao Vencimento
    $vcto=><a href='$loc' target='_blank'>DOWNLOAD</a>  ANEXO: $stur<br></p>";

}
}else{
echo "SEM FATURAS.";

}

?>

Thank you in advance for the help and for any clarifications just contact.

Att,

  • You want to return reservations is want to have, which index as references ? The invoice id?

  • Yes, exactly.

  • This image you posted, is the return of the post function ?

  • Yes, and the result so far. Note that I managed to make each invoice in a link to the file. Now I need to do the same for each of the numbers that follow the attachment (407685,408475,etc...).

  • Good, but apparently, the information is coming correctly from the bank, what you want now is to make each of the reservations a clickable link that points to an address, that’s it ?

  • Yeah, I guess you just treat php. Unfortunately I’m not able to do, I’ve been trying to break my head with a loop, while and for, but I can’t get any results without repeats and still not clickable.

Show 1 more comment

1 answer

0

Well if I understand your doubt add this to the code and it should work:

 echo "<p> Fatura $fatura Emitida dia $emissao Vencimento
       $vcto=><a href='$loc' target='_blank'>DOWNLOAD</a>  
           ANEXO:<a href='url_stur' target='_blank'>$stur</a><br></p>";
  • I had already tried this. However the whole string becomes a gigantic link. This problem is being very frustrating.

  • Right, but what goal do you want then? You can through css, apply a class to the link element, and remove the underline with a "text-Decoration:None", and leave the link underlined only when the mouse is over the link...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.