Jump to content

Css com php e DomPDF


Nicolasuky
Go to solution Solved by gw1500se,

Recommended Posts

Estou gerando uma tabela com informações do banco de dados em PDF, porem no banco tem uma coluna chamada cores, onde armazena 3 cores como segue no código, estou conseguindo gerar o PDF, mas na coluna das cores não estou conseguindo associar a variável $color na propriedade "background-color" da <td>, ou seja, preciso que as celular da coluna cores fiquem com as cores associada ao banco.

Na pagina Html eu consegui fazer mas aqui estou com dificuldades, destaquei a linha que estou com problemas. Estou usando o DomPDF.

Desde já, agradeço a ajuda.

 

<?php    

    include_once("conexao.php");
    $html = '<table border=1';    
    $html .= '<thead>';
    $html .= '<tr>';
    $html .= '<th>CORES</th>';
    $html .= '<th>BANCO</th>';
    $html .= '<th>STATUS ATUAL</th>';
    $html .= '<th>PENDÊNCIA</th>';
    $html .= '<th>PRÓXIMAS ATIVIDADES</th>';
    $html .= '<th>RESPONSÁVEL</th>';
    $html .= '<th>PREVISÃO</th>';
    $html .= '</tr>';
    $html .= '</thead>';
    $html .= '<tbody>';
    
    $result_transacoes = "SELECT * FROM tb_banco";
    $resultado_trasacoes = mysqli_query($conn, $result_transacoes);
    while($row_transacoes = mysqli_fetch_assoc($resultado_trasacoes)){

        $cor = $row_transacoes["cores"];
        if ($cor == "#008000") {
            $color = "green";             
        }else if ($cor == "#ff0000") {
            $color = "red"; 

        }else if ($cor == "#ffff00") {
            $color = "Yellow"; 
        }        

        $html .= '<tr><td style="width:60px; background-color="<?php echo $color;?>"'."</td>";
        $html .= '<td>'.$row_transacoes['banco'] . "</td>";
        $html .= '<td>'.$row_transacoes['status_atual'] . "</td>";
        $html .= '<td>'.$row_transacoes['pendencia'] . "</td>";
        $html .= '<td>'.$row_transacoes['atividade'] . "</td>";
        $html .= '<td>'.$row_transacoes['responsavel'] . "</td>";
        $html .= '<td>'.$row_transacoes['previsao'] . "</td></tr>";        
    }
    
    $html .= '</tbody>';
    $html .= '</table';

......

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.