Ir para conteúdo
Fórum Script Brasil

Todas Atividades

Atualizada automaticamente

  1. Recentemente
  2. mas agora faz um teste ae no seu.. quando se tem mais cadastros um fica dentro das tabelas ou outros ficam de fora.. tentei corrigir mas mesmo assim fica de fora..
  3. nesse ae o meu pega o caminho :: 404 Not Found localhost/polo/nomeimagem.jpg
  4. Hoje
  5. corri o erro agora apareceu a foto apenas acrescentei um ./ <?php $path = __DIR__ . "./fotos/" . $row->foto;
  6. não entendi como assim coloca a culpa em você... não falei isso.. so mudei a barra "/" por "\" ae da erro na linha $src = "data:$type;base64,$data"; ?> Parse error: syntax error, unexpected identifier "data" in C:\xampp\htdocs\polo\etiqueta.php on line 32
  7. Tentei importar a solução PHP no Livewire, mas não deu certo com o Tablet. Mas deu certo com o micro, mas a resolução do micro mudou depois que fiz a atualização do Windows hoje de manhã. Ontem, a minha resolução do notebook era 1360x599, hoje ele está com 1511x665. Em teoria, o código JavaScript não deveria funcionar no Livewire, porque ele é um JavaScript (Ajax) camuflado com a linguagem PHP. É por isso que continuo usando o PHP, eu não confio no Livewire, apesar dele ser muito bacana. arquivo resources > views > components > layouts > app.blade.php <!DOCTYPE html> <html lang="{{ str_replace('_', '-', app()->getLocale()) }}"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="shortcut icon" href="{{ asset('favicon.ico?v=2') }}"> @vite(['resources/css/app.css', 'resources/js/app.js']) <title>{{ $titulo ?? 'Menu' }}</title> </head> <script> window.addEventListener('DOMContentLoaded', () => { const width = window.innerWidth; const height = window.innerHeight; // alert(width+" "+height) // Galaxy Tab S10 Lite // não funciona no Livewire if (width == 880 && height == 1252) { document.body.classList.add('w-[800px]') } // Galaxy Book 4 if (width == 1511 && height == 665) { document.body.classList.add('text-sm') } }); </script> <body class="w-[630px] m-0 m-auto text-lg"> <header class="bg-white shadow-sm flex items-center justify-between font-normal"> <flux:heading class="px-2 font-normal">Livewire</flux:heading> <div class="relative group z-10"> <flux:button icon:trailing="chevron-down" variant="ghost" class="text-gray-500"> {{ $titulo ?? 'Menu' }} </flux:button> <div class="hidden group-hover:block absolute bg-white text-gray-800 rounded-md shadow-lg w-45 "> @if(auth()->user()->id == 1) <div class="flex space-x-4 px-4 py-2"> <a href="/previsao" wire:navigate class="text-gray-500 transition-colors"> Previsão </a> <a href="/diario" wire:navigate class="px-3 text-gray-500 transition-colors"> Diário </a> </div> <a class="block px-4 py-2 text-gray-500" href=/outros wire:navigate>Outros</a> @endif <a class="block px-4 py-2 text-gray-500" href='/orcamento/0/1' wire:navigate>Orçamento</a> <a class="block px-4 py-2 text-gray-500" href=/pagar wire:navigate>Pagar</a> <a class="block px-4 py-2 text-gray-500" href=/receber wire:navigate>Receber</a> <a class="block px-4 py-2 text-gray-500" href=/pessoa wire:navigate>Pessoa</a> <a class="block px-4 py-2 text-gray-500" href=/produto/1 wire:navigate>Produto</a> <a class="block px-4 py-2 text-gray-500" href=/venda wire:navitate>Relatório de Venda</a> </div> </div> <div class="relative group"> <flux:button icon:trailing="chevron-down" variant="ghost" class="text-gray-500"> {{ auth()->user()->nome}} </flux:button> <div class="hidden group-hover:block absolute bg-white text-gray-500 rounded-md shadow-lg w-40"> <flux:button href="/logout" variant="ghost" class="text-gray-500">Sair</flux:button> <flux:button href=# variant="ghost" class="text-gray-500">Mudar Senha</flux:button> </div> </div> </header> @livewireScripts {{ $slot }} </script> </body> </html>
  8. Hahahaha... eu também tive essa dor de cabeça, mas se você prestar atenção na mensagem de erro, dá para ver que ele está procurando a foto no lugar errado. A foto não está na pasta polo, e sim na pasta polo/fotos/. Reveja o seu código, ele não contempla o subdiretório fotos no diretório polo. No meu caso, eu cadastrei o endereço do arquivo dentro do banco de dados, na tb_cadastro, no campo foto, assim: fotos/foto1.webp (veja se esse arquivo existe com o mesmo nome através do gerenciador de arquivos do Windows! qualquer letra errada, tudo dá errado). No meu caso, precisei acrescentar "\" no código. Eu faço de um jeito, e faz de outro jeito, e depois coloca a culpa em mim. Isso sim está errado!!! Hahahahaha...
  9. cara tu e bom em.. vou estudar o codigo e ver onde eu tva errando kkkkkkkkk mas com certeza tem muita diferença.. valeu 👍 so copiei e colei o seu e o meu deu erro kkkkkkkk tem a pasta fotos e tem a pasta tmp ae ele da como se não tivesse encontrado a pasta ou as fotos.. olha..
  10. O meu projeto Orçamento foi feito para o tablet Galaxy S5e do meu irmão. Na base da tentativa e erro, eu descobri que ele tem 630 pixels, e assim desenhei todo o projeto baseado nesse número. Mas nessa semana eu comprei um tablet Galaxy S10 Lite, o meu projeto coube nele, mas sobrou um monte de espaço pelos lados. Com a ajuda do window.innerWidth e o window.innerHeight do JavaScript descobri que o S10 Lite tem 880 x 1252 de resolução. Na base da improvisação, eu pedi para o projeto usar um <body> de 800 pixels, quando ele for trabalhar dentro do S10 Lite, e assim eu tive muita sorte, todo o meu projeto de 630 pixels foram espalhados no espaço de 800 pixels. Claro que existe muita tecnologia como o CSS responsivo. O problema é que eu nem sei mexer com o CSS básico, ainda. *** Escrevi besteira: uma coisa é medir a resolução do micro pelo localhost, e outra bem diferente é medir através da Hostinger *** arquivo appView.php <!DOCTYPE html> <html lang="en"> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"> <script src="https://cdn.tailwindcss.com"></script> <link rel="icon" type="image/svg+xml" sizes="any" href="https://www.php.net/favicon.svg?v=2"> <style> summary { list-style:none } </style> <script> window.addEventListener('DOMContentLoaded', () => { const width = window.innerWidth; const height = window.innerHeight; // alert(width+" "+height) // Galaxy Tab S10 Lite if (width == 880 && height == 1252) { document.body.classList.add('w-[800px]') } // Galaxy Book 4 if (width == 1360 && height == 599) { document.body.classList.add('text-sm') } }); </script> <title>Projeto Classe</title> <body class="w-[630px] m-0 m-auto text-lg">
  11. Yesterday
  12. Veja se na tb_cadastro existe algum visitante com o id=34, eu não tenho: <?php $conn = new mysqli("localhost", "root", "", "polo"); $result = $conn->query("select * from tb_cadastro where id=5"); if ($result->num_rows > 0) { while($row = $result->fetch_assoc()) { echo "<div style='width:500px;margin:0 auto'>"; echo "Nome da Etiqueta: " . $row["nome"]. "<br>"; echo "<img src=". $row['foto']. " width=100px alt='Foto da Etiqueta'></div>"; } }
  13. Esse deu trabalho, tive que mexer na etiqueta.php e no geraetiqueta.php, a foto coloquei na pasta fotos, e no campo foto coloquei coisa do tipo fotos/foto1.webp: etiqueta.php <?php date_default_timezone_set('America/Sao_Paulo'); ?> <!DOCTYPE html> <html lang="pt-br"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Etiquetas dos Cadastros</title> <meta http-equiv="Content-Type" content="charset=utf-8" /> </head> <body> <p><button type="button" onclick="window.open(href='geraetiqueta.php', 'popup', 'fullscreen=1, height=680px, width=900px')">GERAR PDF</button ></p> <h1>Etiquetas de Cadastros</h1> <?php $mysqli=new mysqli("localhost","root","","polo"); $res=$mysqli->query("select * from tb_cadastro"); if($res->num_rows > 0) : ?> <table border='1'> <?php while($row = $res->fetch_object()) : ?> <tr> <th>Foto</th> <th>Matrícula</th> <th>Nome</th> <th>Tipo</th> </tr> <tr> <?php $path = __DIR__ . "/" . $row->foto; $type = mime_content_type($path); $data = base64_encode(file_get_contents($path)); $src = "data:$type;base64,$data"; ?> <td><img src="<?= $src ?>" width="100" /></td> <td><?=$row->matricula?></td> <td><?=$row->nome?></td> <td><?=$row->tipo?></td> </tr> </table> <?php endwhile; else: echo 'Nenhum dado recebido'; endif ?> </body> </html> geraetiqueta.php <?php require __DIR__ . '/vendor/autoload.php'; use Dompdf\Dompdf; use Dompdf\Options; $options = new Options(); ob_start(); include 'etiqueta.php'; $html=ob_get_clean(); $options->setIsRemoteEnabled(true); $dompdf = new Dompdf($options); $dompdf->loadHtml($html); $dompdf->setPaper('A4', 'portrait'); $dompdf->render(); $output = $dompdf->output(); file_put_contents("./tmp/etiqueta.pdf", $output); die("<script>location.href='./tmp/etiqueta.pdf';</script>"); ?>
  14. obrigado por sua dica. assim vou aprendendo.. agora to querendo apresentar a foto antes da matricula.. mas so aparece um quadrado.. a pasta temp já tem no diretorio..
  15. a imagem não aparece na pagina so fica um quadrado.. a imagem esta cadastrada no banco de dados so que la tem varios cadastros com jpeg. jpg, png segue o codigo.. <?php // Exemplo de conexão com o banco de dados $conn = new mysqli("localhost", "root", "", "polo"); // Verificar a conexão if ($conn->connect_error) { die("Erro na conexão: " . $conn->connect_error); } // Buscar os dados da etiqueta e da imagem $sql = "SELECT * FROM tb_cadastro WHERE id = 34"; // Substitua 1 pelo ID desejado $result = $conn->query($sql); if ($result->num_rows > 0) { while($row = $result->fetch_assoc()) { echo "Nome da Etiqueta: " . $row["nome"]. "<br>"; // Decodificar a imagem e exibi-la como base64 para uma tag <img> echo "<img src='data:image/jpg;charset=utf-8;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAAZCAYAAADE 6YVjAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAA ADw/ eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ld GEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2L jE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi 8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdX Q9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL2 5zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC 9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNiAoV2luZG93cykiIH htcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6MEVBMTczNDg3QzA5MTFFNjk3ODM5NjQyRjE2RjA3QTkiIHhtcE1NOkRvY3 VtZW50SUQ9InhtcC5kaWQ6MEVBMTczNDk3QzA5MTFFNjk3ODM5NjQyRjE2RjA3QTkiPiA8eG1wTU06RGVyaXZlZEZyb2 0gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDowRUExNzM0NjdDMDkxMUU2OTc4Mzk2NDJGMTZGMDdBOSIgc3RSZWY6ZG 9jdW1lbnRJRD0ieG1wLmRpZDowRUExNzM0NzdDMDkxMUU2OTc4Mzk2NDJGMTZGMDdBOSIvPiA8L3JkZjpEZXNjcmlwdG lvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PjjUmssAAAGASURBVHjatJaxTsMwEI bpIzDA6FaMMPYJkDKzVYU+QFeEGPIKfYU8AETkCYI6wANkZQwIKRNDB1hA0Jrf0rk6WXZ8BvWkb4kv99vn89kDrfVexB SYgVNwDA7AN+jAK3gEd+AlGMGIBFDgFvzouK3JV/lihQTOwLtOtw9wIRG5pJn91Tbgqk9kSk7GViADrTD4HCyZ0NQnom i51sb0fUyCMQEbp2WpU67IjfNjwcYyoUDhjJVcZBjYBy40j4wXgaobWoe8Z6Y80CJBwFpunepIzt2AUgFjtXXshNXjVm Mh+K+zzp/CMs0CqeuzrxSRpbOKfdCkiMTS1VBQ41uxMyQR2qbrXiiwYN3ACh1FDmsdK2Eu4J6Tlo31dYVtCY88h5ELZI JJ+IRMzBHfyJINrigNkt5VsRiub9nXICdsYyVd2NcVvA3ScE5t2rb5JuEeyZnAhmLt9NK63vX1O5Pe8XaPSuGq1uTrfU gMEp9EJ+CQvr+BJ/AAKvAcCiAR+bf9CjAAluzmdX4AEIIAAAAASUVORK5C YII=" . base64_encode('$row->foto') . "' alt='Foto da Etiqueta'>"; } } else { echo "Nenhuma etiqueta encontrada"; } $conn->close(); ?>
  16. 1 não pode usar o marcador html duas vezes 2 é proibido colocar o botão de comando dentro do <head> 3 você quebrou um monte de célula <td></b></td> 4 precisa ter a pasta temp no diretório do projeto Eu simplifiquei conexao.php e etiqueta.php assim: <?php date_default_timezone_set('America/Sao_Paulo'); ?> <!DOCTYPE html> <html lang="pt-br"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Etiquetas dos Cadastros</title> <meta http-equiv="Content-Type" content="charset=utf-8" /> </head> <body> <p><button type="button" onclick="window.open(href='geraetiqueta.php', 'popup', 'fullscreen=1, height=680px, width=900px')">GERAR PDF</button ></p> <h1>Etiquetas de Cadastros</h1> <?php $mysqli=new mysqli("localhost","root","","polo"); $res=$mysqli->query("select * from tb_cadastro"); if($res->num_rows > 0) : ?> <table border='1'> <?php while($row = $res->fetch_object()) : ?> <tr> <th>Matrícula</th> <th>Nome</th> <th>Tipo</th> </tr> <tr> <td><?=$row->matricula?></td> <td><?=$row->nome?></td> <td><?=$row->tipo?></td> </tr> </table> <?php endwhile; else: echo 'Nenhum dado recebido'; endif ?> </body> </html>
  17. etiqueta.php <?php // DEFINE O FUSO HORARIO COMO O HORARIO DE BRASILIA date_default_timezone_set('America/Sao_Paulo'); ?> <html> <html lang="pt-br"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Etiquetas dos Cadastros</title> <meta http-equiv="Content-Type" content="charset=utf-8" /> <link href='https://fonts.googleapis.com/css?family=Barlow&subset=latin-ext' rel='stylesheet'> <style> body { font-family: 'Barlow'; font-size: 14px; } @page{ margin: 150px 50px ; } body{ font-family: 'Verdana', sans-serif; margin:0px; padding:0px; } .header{ position: fixed; left: 0; right:0; top: -100px; height: 50px; padding: 10px; background: #333; margin-bottom:100px; text-align: center; } .header img{ height: 50px; } .footer{ position: fixed; left: 0; right:0; bottom:0; background: #333; color:#FFF; text-align: center; padding: 10px; } h1{ text-align: center; } table{ width: 100%; border:1px solid #000000ff; padding: 5px; } table tr th{ background: #1b1916ff; color:#FFF; padding:5px; } table tr:nth-child(even) td{ background: #EEE; } .image{ text-align: center; } .image img{ border: 1px solid #CCC; padding:3px; margin:5px; } </style> <p><button type="button" onclick="window.open(href='geraetiqueta.php', 'popup', 'fullscreen=1, height=680px, width=900px')">GERAR PDF</button ></p> </head> <body> <header class="header"> <img src="https://cdn.iconscout.com/icon/premium/png-256-thumb/dev-environment-icon-svg-png-download-3272349.png" alt="" height="50"> </header> <h1>Etiquetas de Cadastros</h1> <?php include('conexao.php'); $sql = "SELECT * FROM tb_cadastro"; $res = $conn->query($sql); if($res->num_rows > 0){ $html = "<table border='1'>"; while($row = $res->fetch_object()){ $html .= "<tr>"; //$html .= "<th>Id</th>"; $html .= "<th>Matrícula</th>"; $html .= "<th>Nome</th>"; $html .= "<th>Tipo</th>"; //$html .= "<th>Placa</th>"; //$html .= "<th>Veículo</th>"; //$html .= "<th>Cidade</th>"; //$html .= "<th>Uf</th>"; //$html .= "<th>Empresa</th>"; //$html .= "<th>Data</th>"; //$html .= "<th>Entrada</th>"; //$html .= "<th>Saída</th>"; $html .= "</tr>"; $html .= "<tr>"; //$html .= "<td>$row->id</b></td>"; $html .= "<td>$row->matricula</b></td>"; $html .= "<td>$row->nome</b></td>"; $html .= "<td>$row->tipo</b></td>"; //$html .= "<td>$row->placa</b></td>"; //$html .= "<td>$row->veiculo</b></td>"; //$html .= "<td>$row->cidade</b></td>"; //$html .= "<td>$row->uf</b></td>"; //$html .= "<td>$row->empresa</b></td>"; //$html .= "<td>$row->dataentrada</b></td>"; //$html .= "<td>$row->horaentrada</b></td>"; //$html .= "<td>$row->horasaida</td>"; $html .= "</tr>"; } $html .= "</table>"; }else{ $html .= 'Nenhum dado recebido'; } // print $html; echo $html; ?> <footer class="footer"> Gerado em <?php echo (new DateTime())->format('d/m/Y H:i:s')?> </footer> </body> </html> conexao.php <?php $servidor = "localhost"; $usuario = "root"; $senha = ""; $dbname = "polo"; //Criar a conexao $conn = mysqli_connect($servidor, $usuario, $senha, $dbname); if(!$conn){ die("Falha na conexao: " . mysqli_connect_error()); }else{ //echo "Conexao realizada com sucesso"; } ?> geraetiqueta.php <?php // DEFINE O FUSO HORARIO COMO O HORARIO DE BRASILIA date_default_timezone_set('America/Sao_Paulo'); require __DIR__ . '/vendor/autoload.php'; use Dompdf\Dompdf; $dompdf = new Dompdf(); ob_start(); // include 'etiqueta.php'; // $html=ob_get_clean(); // $dompdf->loadHtml($html); $dompdf->setPaper('A4', 'portrait'); $dompdf->render(); $output = $dompdf->output(); file_put_contents("./tmp/etiqueta.pdf", $output); die("<script>location.href='./tmp/etiqueta.pdf';</script>"); ?>
  18. Foi sem querer que descobri que é possível executar o <input type="file"> clicando apenas no <label>, e isso abriu a possibilidade de ocultar o botão "selecionar o arquivo" e também a mensagem "nenhum arquivo selecionado", através de uma gambiarra, reduzindo o tamanho do marcador <input> para zero: <?php if(isset($_GET['rota'])) { echo "<div class='w-[500px] mt-[100px] m-0 m-auto'> O nome do arquivo é ".substr($_GET['rota'],12)."</div>"; } ?> <script src="https://cdn.tailwindcss.com"></script> <div class="w-[500px] mt-[200px] m-0 m-auto"> <label for="arquivo" class="w-[200px] bg-gray-200 border rounded-lg px-2 py-2"> Selecione o arquivo </label> <input type="file" name="arquivo" id="arquivo" class="w-[0px]" onchange="location.replace('?rota='+this.value)"> </div>
  19. Você também pode tentar incluir tudo numa só página: <style> h1 { text-align: center; color: #0077cc; } </style> <h1>Olá mundo</h1>
  20. Última semana
  21. Olá. Vamos lá. Como você está usando o Xampp, seus arquivos têm que estar na pasta htdocs do Xampp (ou numa pasta dentro dessa pasta). para verificar isso, use o gerenciador de arquivos do windows (10) ou windows explorer (7). após isso, você deve acessar suas páginas pelo navegador usando o seguinte comando: http://localhost/seuarquivo.php ou http://localhost/suapasta/seuarquivo.php + abaixo segue um print de exemplo p/ você ver: ah, 1 detalhe: eu uso xcampp tb e toda vez que reinicio o computador preciso iniciar o Xampp (Apache e Mysql) também (muito chato isso, prefiro instalar tudo separado mas tenho preguiça..rs... qqer coisa, retorne e sucesso
  22. Bom dia Muito obrigado pelo retorno Sim tenho o Xampp instalado E todos os arquivos estão na mesma pasta. Se funcionou com vocês teria que esta funcionando aqui também. Qual será o erro? muito estranho
  23. deu certo aqui. valeu pela ajuda.. é esse cadastro de 50 crianças e foda.
  24. Verifique se os dois arquivos estão no mesmo diretório, o arquivo que contém html/php tem que ter a extensão php, e o outro arquivo tem ser o tarefas.css Eu já gosto mais do tailwind: <?php session_start(); if (isset($_GET['nome'])) { $_SESSION['lista_tarefas'][] = $_GET['nome']; } if (isset($_SESSION['lista_tarefas'])) { $lista_tarefas = $_SESSION['lista_tarefas']; } else { $lista_tarefas = array(); } // include "template.php"; ?> <html> <head> <meta charset="utf-8" /> <title>Gerenciador de Tarefas</title> <script src="https:cdn.tailwindcss.com"></script> </head> <body class="font-sans bg-[#f4f6f8] m-5 text-[#333] w-[500px] m-0 m-auto"> <h1 class="text-center text-[#0077cc] text-3xl text-semibold mt-5">Gerenciador de Tarefas</h1> <form class="mb-[20px]"> <fieldset class="border-2 border-[#0077cc] rounded-lg p-4 mb-4 bg-white"> <legend class="font-bold text-[#0077cc]">Nova tarefa</legend> <input type="text" name="nome" class="w-[95%] p-2 mt-1 mb-2 border border-gray-400 rounded-md" placeholder="Tarefa:" /> <input type="submit" value="Cadastrar" class="bg-[#0077cc] text-white border-none px-4 py-2 rounded-lg cursor-pointer hover:bg-[#005fa3]"/> </fieldset> </form> <table class="w-full border-collapse bg-white"> <tr class="even:bg-[#f9f9f9]"> <th class="border border-gray-300 px-4 py-2 text-left bg-[#0077cc] text-white">Tarefas</th> </tr> <?php foreach ($lista_tarefas as $tarefa) : ?> <tr class="even:bg-[#f9f9f9]" > <td class="border border-gray-300 px-4 py-2 text-left"><?=$tarefa?> </td> </tr> <?php endforeach; ?> </table> <textarea name="descricao" placeholder="Descrição (Opcional):" class="w-[95%] p-2 mt-1 border border-gray-400 rounded-md"></textarea> <input type="text" name="prazo" placeholder="Prazo (Opcional):" class="w-[95%] p-2 mt-1 border border-gray-400 rounded-md"/> </label> <fieldset class="border-2 border-[#0077cc] rounded-lg p-4 mb-4 bg-white"> <legend class="font-bold text-[#0077cc]">Prioridade:</legend> <label class="block my-[10px]"> <input type="radio" name="prioridade" value="baixa" checked /> Baixa <input type="radio" name="prioridade" value="media" /> Média <input type="radio" name="prioridade" value="alta" /> Alta </label> </fieldset> <label class="block my-[10px]"> Tarefa concluída: <input type="checkbox" name="concluida" value="sim" /> </label> <input type="submit" value="Cadastrar" class="bg-[#0077cc] text-white border-none px-4 py-2 rounded-lg cursor-pointer hover:bg-[#005fa3]" /> </body> </html>
  25. Depois que instalei a biblioteca do dompdf com o comando composer require dompdf/dompdf eu precisei alterar o arquivo print.pdf: <?php require __DIR__ . '/vendor/autoload.php'; use Dompdf\Dompdf; $dompdf = new Dompdf(); ob_start(); // include 'relatorio.php'; // $html=ob_get_clean(); // $dompdf->loadHtml($html); $dompdf->setPaper('A4', 'landscape'); $dompdf->render(); $output = $dompdf->output(); file_put_contents("./tmp/relatorio.pdf", $output); die("<script>location.href='./tmp/relatorio.pdf';</script>"); O projeto polo3 que mandei para você não contempla relatório em pdf, pois ele está preso no critério da identificação do visitante. No seu exemplo, você trabalha com "matrícula". Vamos supor que entra 50 ônibus escolares com 50 crianças em cada uma delas, nenhuma trouxe documento e nem sabem o que é nome completo, como é que vamos cadastra-las?
  26. boa tarde.. tenho um relatorio que vem de um banco de dados mysql. ate ae tudo beleza. recebo os dados correto.. fiz um arquivo relatorio.php pra receber esses dados formatando com html e fiz um print.php pra imprimir em pdf o problema que no relatorio.php ta perfeito mas a hora que gera o pdf vem tudo desconfigurado.. essa tela e do relatorio.php essa outra e do pdf gerado na saida. segue o codigo fonte pra análise RELATORIO.PHP <html> <html lang="pt-br"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Relatório de Entradas e Saídas</title> <style> @page{ margin: 150px 50px ; } body{ font-family: 'Verdana', sans-serif; margin:0px; padding:0px; } .header{ position: fixed; left: 0; right:0; top: -100px; height: 50px; padding: 10px; background: #333; margin-bottom:100px; text-align: center; } .header img{ height: 50px; } .footer{ position: fixed; left: 0; right:0; bottom:0; background: #333; color:#FFF; text-align: center; padding: 10px; } h1{ text-align: center; } table{ width: 100%; border:1px solid #333; padding: 5px; } table tr th{ background: #333; color:#FFF; padding:5px; } table tr:nth-child(even) td{ background: #EEE; } .image{ text-align: center; } .image img{ border: 1px solid #CCC; padding:3px; margin:5px; } </style> </head> <body> <header class="header"> <img src="https://www.botecodigital.dev.br/wp-content/themes/boteco_v4/img/logob.png" alt="" height="50"> </header> <h1>Relatório de Entradas e Saídas</h1> <form action="print.php" method="post"> <button type="submit" name="acao" value="gera_pdf">GERAR PDF</button> </form> <form action="r_entrada.php" method="post"> <button type="submit" name="acao" value="gera_pdf">VOLTAR</button> </form> <?php include('conectprint.php'); $sql = "SELECT * FROM tb_entrada"; $res = $conn->query($sql); if($res->num_rows > 0){ $html = "<table border='0'>"; while($row = $res->fetch_object()){ $html .= "<tr>"; // <th>Foto</th> $html .= "<th>Id</th>"; $html .= "<th>Matrícula</th>"; $html .= "<th>Nome</th>"; $html .= "<th>Tipo</th>"; $html .= "<th>Placa</th>"; $html .= "<th>Veículo</th>"; $html .= "<th>Cidade</th>"; $html .= "<th>Uf</th>"; $html .= "<th>Empresa</th>"; $html .= "<th>Data</th>"; $html .= "<th>Entrada</th>"; $html .= "<th>Saída</th>"; $html .= "</tr>"; $html .= "<tr>"; $html .= "<td>$row->id</b></td>"; $html .= "<td>$row->matricula</b></td>"; $html .= "<td>$row->nome</b></td>"; $html .= "<td>$row->tipo</b></td>"; $html .= "<td>$row->placa</b></td>"; $html .= "<td>$row->veiculo</b></td>"; $html .= "<td>$row->cidade</b></td>"; $html .= "<td>$row->uf</b></td>"; $html .= "<td>$row->empresa</b></td>"; $html .= "<td>$row->dataentrada</b></td>"; $html .= "<td>$row->horaentrada</b></td>"; $html .= "<td>$row->horasaida</td>"; $html .= "</tr>"; } $html .= "</table>"; }else{ $html .= 'Nenhum dado recebido'; } // print $html; echo $html; ?> <footer class="footer"> Gerado em <?php echo (new DateTime())->format('d/m/Y h:i:s')?> </footer> </body> </html> Print.php <?php // chamando os arquivos necessários do DOMPdf require __DIR__ . '/vendor/autoload.php'; // Ajuste o caminho se necessário use Dompdf\Dompdf; require_once 'relatorio.php'; // inicializando o objeto Dompdf $dompdf = new Dompdf(); // coloque nessa variável o código HTML que você quer que seja inserido no PDF // carregamos o código HTML no nosso arquivo PDF $dompdf->loadHtml($html); // (Opcional) Defina o tamanho (A4, A3, A2, etc) e a oritenação do papel, que pode ser 'portrait' (em pé) ou 'landscape' (deitado) $dompdf->setPaper('A4', 'landscape'); // Renderizar o documento $dompdf->render(); // pega o código fonte do novo arquivo PDF gerado $output = $dompdf->output(); // defina aqui o nome do arquivo que você quer que seja salvo file_put_contents("./tmp/relatorio.pdf", $output); // redirecionamos o usuário para o download do arquivo die("<script>location.href='./tmp/relatorio.pdf';</script>"); ?> conectprint.php <?php $servidor = "localhost"; $usuario = "root"; $senha = ""; $dbname = "polo"; //Criar a conexao $conn = mysqli_connect($servidor, $usuario, $senha, $dbname); if(!$conn){ die("Falha na conexao: " . mysqli_connect_error()); }else{ //echo "Conexao realizada com sucesso"; } ?>
  27. Olá. Ta funcionando sim. você tem certeza que instalou o servidor (Apache ou Xampp)?
  28. Boa noite Estou fazendo um estudo em PHP, HTML, CSS e MySql, mas quando executo o script no navegado não esta aplicando o arquivo CSS, sou amador nessas linguagem, espero que tenham paciência. Segue os Códigos: .PHP <?php session_start(); if (isset($_GET['nome'])) { $_SESSION['lista_tarefas'][] = $_GET['nome']; } if (isset($_SESSION['lista_tarefas'])) { $lista_tarefas = $_SESSION['lista_tarefas']; } else { $lista_tarefas = array(); } include "template.php"; ?> .HTML <html> <head> <meta charset="utf-8" /> <title>Gerenciador de Tarefas</title> <link rel="stylesheet" href="tarefas.css" type="text/css" /> </head> <body> <h1>Gerenciador de Tarefas</h1> <form> <fieldset> <legend>Nova tarefa</legend> <label> Tarefa: <input type="text" name="nome" /> </label> <input type="submit" value="Cadastrar" /> </fieldset> </form> <table> <tr> <th>Tarefas</th> </tr> <?php foreach ($lista_tarefas as $tarefa) : ?> <tr> <td><?php echo $tarefa; ?> </td> </tr> <?php endforeach; ?> </table> <label> Descrição (Opcional): <textarea name="descricao"></textarea> </label> <label> Prazo (Opcional): <input type="text" name="prazo" /> </label> <fieldset> <legend>Prioridade:</legend> <label> <input type="radio" name="prioridade" value="baixa" checked /> Baixa <input type="radio" name="prioridade" value="media" /> Média <input type="radio" name="prioridade" value="alta" /> Alta </label> </fieldset> <label> Tarefa concluída: <input type="checkbox" name="concluida" value="sim" /> </label> <input type="submit" value="Cadastrar" /> </body> </html> .CSS /* tarefas.css */ /* Estilo geral da página */ body { font-family: Arial, sans-serif; background-color: #f4f6f8; margin: 20px; color: #333; } /* Título */ h1 { text-align: center; color: #0077cc; } /* Formulário */ form { margin-bottom: 20px; } fieldset { border: 2px solid #0077cc; border-radius: 8px; padding: 15px; margin-bottom: 15px; background-color: #fff; } legend { font-weight: bold; color: #0077cc; } label { display: block; margin: 10px 0; } /* Campos de entrada */ input[type="text"], textarea { width: 95%; padding: 8px; margin-top: 5px; border: 1px solid #aaa; border-radius: 5px; } /* Botões */ input[type="submit"] { background-color: #0077cc; color: white; border: none; padding: 10px 15px; border-radius: 6px; cursor: pointer; } input[type="submit"]:hover { background-color: #005fa3; } /* Tabela de tarefas */ table { width: 100%; border-collapse: collapse; background: #fff; } th, td { border: 1px solid #ddd; padding: 10px; text-align: left; } th { background-color: #0077cc; color: white; } tr:nth-child(even) { background-color: #f9f9f9; }
  1. Mais Resultados


  • Estatísticas dos Fóruns

    • Tópicos
      152,5k
    • Posts
      652,5k
×
×
  • Criar Novo...