0
大家好我在做一个表格,因为在drupal中,我有一个文本框和一个按钮,输入一个代码(varchar),并将其与sqlserver中的记录进行比较在执行验证时输入的代码在表单中存在的DB)使用存储过程执行iframe。从SQL服务器检索结果集的问题
这是代码,我认为我做错了php代码,并选择它,因为输入查询值的时刻不会生成文本“所有权利”或“咨询数量不存在” “在他发现确实
我感谢那些谁告诉我,帮助和指导
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Buscador php</title>
<form method="POST" action="" onSubmit="return validarForm(this)">
<input type="text" placeholder="Buscar usuario" name="palabra">
<input type="submit" value="Buscar" name="buscar">
</form>
</meta>
<script type="text/javascript">
function validarForm(formulario)
{
if(formulario.palabra.value.length==0)
{ //¿Tiene 0 caracteres?
formulario.palabra.focus(); // Damos el foco al control
alert('Debes rellenar este campo'); //Mostramos el mensaje
return false;
} //devolvemos el foco
return true; //Si ha llegado hasta aquí, es que todo es correcto
}
</script>
</html>
</head>
<?php
//si existe una petición
if($_POST['buscar'])
{
$usuario= '';
$pass = '';
$servidor = '';
$basedatos = '';
$info = array('Database'=>$basedatos, 'UID'=>$usuario, 'PWD'=>$pass);
$conexion = sqlsrv_connect($servidor, $info);
if(!$conexion){
die(print_r(sqlsrv_errors(), true));
}
echo 'Conectado';
$buscar = $_POST["palabra"];
$arrojado = sqlsrv_query("SELECT ID from Venta
where ID like '%buscar%'",$conexion) or
die("Problemas en el select:".sqlsrv_error());
?>
//$resultado = sqlsrv_fetch_array($arrojado);
<?php
$valor = $resultado['aleatoria']; //LE ASIGNAMOS UNA VARIABLE AL RESULTADO DE LA CONSULTA
//COMPARAMOS CON UNA CONDICIONAL
if($arrojado == $buscar){
echo"todo bien";
}
else {
echo "El numero consultado no existe";
?>
HOLA!请尽管英语,但格拉齐。 –
'
@ Fred-ii-你的PHP技能可能是* molto bene *但你的西班牙语不是! ;) – miken32