Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Ola,
preciso de ajuda em um código de busca em php mysql!
tem um form de busca:
com tres campos: vendedor, mes e ano.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="[http://www.w3.org/1999/xhtml">](http://www.w3.org/1999/xhtml)
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table width="100%" border="0" cellpadding="0" cellspacing=" 0">
<tr>
<td width="15"><div align="center" class="style13 style13"><img src="Imagens/cadeado.gif" alt="" width="30" height="30" /></div></td>
<td class="style7 style13 style13"><strong><b><strong>Free Travel Turismo</strong></b> - <b><b><a href="fechar.php">Fechar Janela</a></b></b></strong></td>
</tr>
<tr>
<td> </td>
<td><form id="form1" name="form1" method="get" action="resultado_busca_os8.php">
<table width="332" border="0">
<tr>
<td width="178" class="style7 style13 style13">VENDEDOR:</td>
<td width="144"><div align="right"> <span class="style7 style13 style13">
<input type="text" name="vendedor" id="vendedor" />
</span></div></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
</table>
<table width="332" border="0">
<tr>
<td width="178" class="style7 style13 style13">MES:</td>
<td width="144"><div align="right"> <span class="style7 style13 style13">
<input type="text" name="mes" id="mes" />
</span></div></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
</table>
<table width="332" border="0">
<tr>
<td width="178" class="style7 style13 style13">ANO:</td>
<td width="144"><div align="right">
<span class="style7 style13 style13">
<input type="text" name="ano" id="ano" />
</span></div></td>
</tr>
<tr>
<td> </td>
<td><div align="right">
<span class="style7 style13 style13">
<input type="submit" name="button" id="button" value="Buscar" />
</span></div></td>
</tr>
</table>
</form></td>
</tr>
</table>
</body>
</html><?php
include "config.php"; //conexão mysql
$exec = mysql_query("SELECT * FROM os WHERE vendedor LIKE '%$vendedor%' OR mes LIKE '%$mes%' OR ano LIKE '%$ano%'") or die("<script>alert('ERRO! Não foi possível conectar ao banco de dados.');location.href='javascript:history.go(-1)';</script>");
$total = mysql_num_rows($exec);
?><html xmlns="[http://www.w3.org/1999/xhtml">](http://www.w3.org/1999/xhtml)
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Relatório de OS</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<img src="Imagens/FreeTravelBrazilLogo.png" width="200" height="69" />
<table width="100%" border="0" cellpadding="0" cellspacing=" 0">
<tr>
<td width="15"><div align="center"><img src="Imagens/7513_32x32.png" width="32" height="32" /></div></td>
<td><strong>Free Travel Turismo: Relatório de OS : <?php echo $row_Recordset1['vendedor']; ?>, <?php echo $row_Recordset1['mes']; ?>, <?php echo $row_Recordset1['ano']; ?></strong></td>
</tr>
<tr>
<td> </td>
<td><table width="100%" border="0" align="center">
<tr bgcolor="#0099FF">
<td bgcolor="#99FF00">OS N°</td>
<td bgcolor="#99FF00">Reserva N°</td>
<td bgcolor="#99FF00">Funcionario</td>
<td bgcolor="#99FF00">Mes Lançado</td>
<td bgcolor="#99FF00">Ano Lançado</td>
<td bgcolor="#99FF00">Pax</td>
<td bgcolor="#99FF00">Serviço</td>
<td bgcolor="#99FF00">Motorista</td>
<td bgcolor="#99FF00">Guia</td>
<td bgcolor="#99FF00">Vendedor</td>
<td bgcolor="#99FF00">Valor</td>
</tr>
<?php do { ?>
<tr>
<td><?php echo $row_Recordset1['codigo']; ?></td>
<td><?php echo $row_Recordset1['codigo2']; ?></td>
<td><?php echo $row_Recordset1['funcionario']; ?> </td>
<td><?php echo $row_Recordset1['mes']; ?> </td>
<td><?php echo $row_Recordset1['ano']; ?></td>
<td><?php echo $row_Recordset1['pax']; ?> </td>
<td><?php echo $row_Recordset1['servico']; ?> </td>
<td><?php echo $row_Recordset1['motorista']; ?> </td>
<td><?php echo $row_Recordset1['guia']; ?> </td>
<td><?php echo $row_Recordset1['vendedor']; ?> </td>
<td><?php echo $row_Recordset1['valor_total']; ?> </td>
</tr>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($exec)); ?>
</table></td>
</tr>
</table>
<table width="54" border="0" align="right">
<tr>
<td><a href="#" onclick="window.print();"><img src="Imagens/Print_48.png" alt="ASD" width="48" height="48" border="0" /></a></td>
</tr>
</table>
</p>
<a href="busca_os8.php" class="style19">Fazer nova busca</a>
</body>
</html>aparece todos os resultados!
se alguem puder me ajudar! agradeço!
Carregando comentários...