Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Boa noite pessoal, estou com alguns problemas em um formulario de pesquisa, se possível gostaria de contar com a ajuda de vocês.
Seguinte:
1 Não consigo fazer com que ao digitar em maiscula encontra o resultado, em minusculo não encontra (a coluna do bd esta em maiuscula)
2 só consigo a pesquisa com uma coluna, não acerto o código correto para duas colunas.
Zgradeço a ajuda.
Código de pesquisa
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$colname_Recordset1 = "-1";
if (isset($_GET['Código'])) {
$colname_Recordset1 = $_GET['Código'];
}
mysql_select_db($database_conexao, $conexao);
$query_Recordset1 = sprintf("SELECT * FROM tblprodutos WHERE Código LIKE %s", GetSQLValueString("%" . $colname_Recordset1 . "%", "double"));
$Recordset1 = mysql_query($query_Recordset1, $conexao) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
$colname_Recordset2 = "-1";
if (isset($_GET['Código'])) {
$colname_Recordset2 = $_GET['Código'];
}
mysql_select_db($database_conexao, $conexao);
$query_Recordset2 = sprintf("SELECT * FROM tblprodutos WHERE Código = %s", GetSQLValueString($colname_Recordset2, "text"));
$Recordset2 = mysql_query($query_Recordset2, $conexao) or die(mysql_error());
$row_Recordset2 = mysql_fetch_assoc($Recordset2);
$totalRows_Recordset2 = mysql_num_rows($Recordset2);
?>
Form com campo de pesquisa
<form id="formulario" name="formulario" method="get" action="resultado.php">
<div align="right">
<script>
function Esvazia(valor_campo){
if (valor_campo.value == valor_campo.defaultValue)
valor_campo.value='';
}
function Padrao(valor_campo){
if (valor_campo.value == '')
valor_campo.value=valor_campo.defaultValue;
}
</script>
<input name="palavra" type="text" class="style1" id="palavra" onfocus="Esvazia(this)" onblur="Padrao(this)" value="Encontre o Produto" />
<input type="image" ation="submit form" name="enviar" id="enviar" src="imagens/img_index/botaoenviar.png" />
</div>
</form>Carregando comentários...