Painel com Checkbox ajuda

Enviada por marcio 
marcio
Painel com Checkbox ajuda
08 de April de 2014 às 01:07AM
Boa Noite, tenho um painel que mostra dos dados da db assim

http://s27.postimg.org/k7g8ua0ib/image.png

marcando as duas checbox e clicando imprimir varias

ele muda para o print.php o print php código esta assim

/// ACIMA A FUNÇAO DE LIGAÇÃO A BD

foreach ($_GET['print'] as $printid) echo "$printid<br>" ;
foreach ($_POST['print'] as $item)
{
echo "Numero da Qm: $nqm <br /> ".$_POST['data'][$id]."<br /> ".$_POST['link2'][$idx]."<br />Link 3 ".$_POST['link3'][$idx]."<br />";

}

e no painel as checkbox tao assim

<form id="input" action="2.php" method="post">
<input class="btn btn-default" type="submit" value="Imprimir Varias">
botao de imprimir

e a checkbox esta assim
<input type="checkbox" name="print[]" value="<?php echo $row["id"]; ?>" >
</td>
</tr>

e os dados surgem assim

Numero da Qm:


Link 3
Numero da Qm:


Link 3

não mostra o $nqm o campo numero da qm fica em branco


alguém me pode ajudar?

cumprimentos
Wéllingthon M. de Souza
Re: Painel com Checkbox ajuda
08 de April de 2014 às 03:21PM
Boa Tarde, Marcio.

Onde que se encontra a variável $nqm ? Pois o uso do foreach não consta essa variavel, você ta pegando ela via POST ? se for troque ela pela variável $item

foreach ($_POST['print'] as $item)
{
echo "Numero da Qm: $item <br /> ".$_POST['data'][$id]."<br /> ".$_POST['link2'][$idx]."<br />Link 3 ".$_POST['link3'][$idx]."<br />";

}
marcio
Re: Painel com Checkbox ajuda
08 de April de 2014 às 11:02PM
nao estou a conseguir queria mesmo ajuda por favor, no print php surge assim

http://s24.postimg.org/ka7xy7cpg/image.jpg

depois de marcar duas checkbox e clicar no botao imprimir

eu individualmente funciona fica assim

http://s10.postimg.org/sug1haj6w/2321.jpg

os campos a vermelho é o que mostra da db esta tudo certo quero igual mas com as chekbox usando uma mostra um usando outra mostra duas.... o código actual do print2 é

<?php

mysql_connect("localhost", "teste", "Filipe13")or die("cannot connect");
mysql_select_db("fmcjr_base1") or die("cannot select DB");

$id=$_GET['id'];


?>
<?php
$limite=count($_POST['print']);
for($i=0;$i<$limite;$i++){$rows=mysql_fetch_array($result);echo'

dentro do echo esta o HTML com o formulário onde ira aparecer e nos campos esta assim

<?php echo"{$rows["nqm"]}?>


--------------------------------------------------------
Wéllingthon M. de Souza
Re: Painel com Checkbox ajuda
09 de April de 2014 às 07:49PM
Boa Tarde, Marcio.

Teria como você postar o código completo ?
marcio
Re: Painel com Checkbox ajuda
09 de April de 2014 às 10:39PM
http://informatica.fmcjr.pt/panel/Code.zip

Contem o admin php onde tem a checkbox que aparece com os dados da db e contem o 2.php que é o print q n mostra os campos da db
Wéllingthon M. de Souza
Re: Painel com Checkbox ajuda
10 de April de 2014 às 11:38AM
Marcio, depois de analisar achei o erro troque o código do script 2.php por esse e vê se vai funcionar.


<?php

$limite=count($_POST['print']);

for($i=0;$i<$limite;$i++){
$id = $_POST['print'][$i];
$sql="SELECT * FROM d3 WHERE id = '$id'";
$result=mysql_query($sql);$rows=mysql_fetch_array($result);
?>

<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title></title>
<style>
body
{


font-family:Arial;

}


td
{

padding:0;
}
.header h2
{
padding-left: 20px;
padding-right: 20px;
padding-top: 20px;
font-size: 18px;
color: #0A73C3;
}

.header h3
{
padding-bottom: 20px;
padding-left: 20px;
padding-right: 20px;
font-size: 14px;
color: #666666;
}

.np1
{
color: #666;
font-size: 14px;
margin: -18px 18px 0;
}

.mp1
{
float: right;
margin: 0 22px 0 0;
}

.header_sub
{
width: 960px;
margin: 5px 0 0;
border-radius: 5px 5px 0 0;
}

.header_sub h2
{
padding: 20px;
font-size: 18px;
color: #0A73C3;
margin: -15px 3px 0 0;
height: 10px;
}

#f1
{
padding-top: 10px;
}

#ip1
{
width: 100%;
text-align: justify;
font-size: 12px;
color: #333;
}

#ip1 h3
{
font-size: 12px;
}

.im1
{
float: right;
margin: -40px 0 0 0;
font-size: 8px;
}

.alfin
{
margin-left: 18px;
width: 300px;
color: #2b2b2b;
width: 400px;
font-size: 13px;
background: url("/images/bg.widget.png") repeat scroll;
border: 0.3px solid #b6b6b6;
}

.p th
{
font-size: 12px;
width: 140px;
}

.prdt tr
{
background: #fff;
}

.espaco
{
height: 5px;
}

#borderrightCF
{
border-right: 1px solid #ccc;
}

.alfin
{
padding: 10px 20px 10px;
font-size: 13px;
border-bottom: 1px solid #f1f1f1;
}

.alrsp
{
margin: -18px 0px 0;
font-size: 13px;
}

.alrsp span
{
color: #000;
text-decoration: underline;
margin: 0 5px;
}

.albr
{
padding: 10px 0 0 0;
}

.iwg
{
font-size: 9px;
color: #0A73C3;
width: 200px;
text-align: justify;
}

.tp01
{
border-collapse: collapse;
}

.tp01 th
{
color: white;
border: 1px solid #e4e4e4;
}

.tp01 td, .myTable th
{
padding: 5px;
border: 1px solid #e4e4e4;
}
.auto-style1
{
height: 30px;
width: 566px;
}
.auto-style3
{
width: 609px;
}
</style>
</head>
<form id="imprimir">
<?php echo "{$rows["nqm"]}" ; ?>
<body bgcolor="#e4e4e4" topmargin="0" leftmargin="0" marginheight="0" marginwidth="0" style="-webkit-font-smoothing: antialiased; width: 100% !important; background: #e4e4e4; -webkit-text-size-adjust: none;">

<table width="100%" cellpadding="0" cellspacing="0" border="0" bgcolor="#e4e4e4">
<tr>
<td bgcolor="#e4e4e4" width="100%">

<table width="960" cellpadding="0" cellspacing="0" border="0" align="center" class="table">
<tr>
<td width="960" class="cell">
<table align="center" style="width: 960px; height: auto; background: #fff; border-radius: 5px 5px 5px 5px; border: 1px solid #ccc; padding-bottom: 15px;">
<tr>
<td>
<div class="header_sub">
<table width="324">
<tr>
<?php echo $rows["nqm"]; ?>
<td width="316">
<h2>Greatenergy, Folha de Obra</h2>
<button type="button" class="btn btn-default" onClick="window.print()">Imprimir</button>
<button type="button" class="btn btn-default" onClick="admin.php">Exportar Para PDF</button>
</td>
</tr>
</table>
<table class="tp01" cellpadding="0" cellspacing="0" border="1" align="center" width="100%">
<tr style="border: 1px solid #ccc;">
<td style="padding-left: 20px; height: 30px;" width="121"><strong>Nª QM:</strong></td>
<td width="156" style="color: #666; text-align: center;"><?php echo $rows["nqm"]; ?></td>
<td width="147" style="color: #000000; text-align: center;"><strong>Data:<span style="color: #666"></span></strong></td>
<td width="109" style="color: #666; text-align: center;"><?php echo $rows["data"]; ?></td>
<td width="155" style="color: #000000; text-align: center;"><strong>Balastro:</strong></td>
<td width="91" style="color: #000000">&nbsp;</td>
<td width="114" style="color: #000000; text-align: center;"><strong>Lâmpada:</strong></td>
<td width="49" style="color: #000000">&nbsp;</td>
</tr>
<tr style="border: 1px solid #ccc;">
<td style="padding-left: 20px; height: 30px;"><strong>Nº PT:</strong></td>
<td style="color:#666"><strong style="text-align: center"><?php echo $rows["npt"]; ?></strong></td>
<td style="color: #000000; text-align: center;"><strong>Doc Global Nº:</strong></td>
<td style="color: #666; text-align: center;"><?php echo $rows["docn"]; ?></td>
<td style="color: #000000; text-align: center;"><strong>Balastro:</strong></td>
<td style="color: #000000">&nbsp;</td>
<td style="color: #000000; text-align: center;"><strong>Lâmpada:</strong></td>
<td style="color: #000000">&nbsp;</td>
</tr>
<tr style="border: 1px solid #ccc;">
<td style="padding-left: 20px; height: 30px;"><strong>Conselho:</strong></td>
<td style="color:#666"><strong style="text-align: center"><?php echo $rows["conselho"]; ?></strong><span style="text-align: center"></span></td>
<td style="color: #000000; text-align: center;"><strong>Ligador 16/95:</strong></td>
<td style="color: #000000">&nbsp;</td>
<td style="color: #000000; text-align: center;"><strong>Fusivel 10x38:</strong></td>
<td style="color: #000000">&nbsp;</td>
<td style="color: #000000">&nbsp;</td>
<td style="color: #000000">&nbsp;</td>
</tr>
<tr style="border: 1px solid #ccc;">
<td style="padding-left: 20px; height: 30px;" colspan="8"><strong>Morada: </strong><?php echo $rows["morada"]; ?></td>
</tr>
<tr style="border: 1px solid #ccc;">
<td style="padding-left: 20px; height: 30px;" colspan="8"><p><strong>Descrição da Anomalia: </strong><?php echo $rows["observ"]; ?></p>
<p>&nbsp;</p></td>
</tr>
<tr style="border: 1px solid #ccc;">
<td colspan="8" bgcolor="#DFDFDF" style="padding-left: 20px; height: 30px; color: #B7B7B7;">&nbsp;</td>
</tr>
<tr style="border: 1px solid #ccc;">
<td colspan="8" bgcolor="#FFFFFF" style="padding-left: 20px; height: 30px; color: #000000;"><strong>Executante:<?php echo $rows["executante"]; ?></strong></td>
</tr>
</table>
</div>
</td>
</tr>
</table>
</table>
</form>
</td>
</tr>
</table>
</body>
</html>
<?php
}
?>
marcio
Re: Painel com Checkbox ajuda
10 de April de 2014 às 12:55PM
Funcionou muito Obrigado agora uns ajustes blz valeu
Wéllingthon M. de Souza
Re: Painel com Checkbox ajuda
10 de April de 2014 às 01:05PM
Opa, por nada. Se precisar estou a disposição.
marcio
Re: Painel com Checkbox ajuda
10 de April de 2014 às 01:05PM
Wéllingthon M. de Souza valeu

5* para este utilizador
Você precisa estar logado no PHPBrasil.com para poder enviar mensagens para os nossos fóruns.

Faça o login aqui.