mekker 0 Posted September 10, 2015 Report Share Posted September 10, 2015 Estou tentando fazer uma consulta de usuário do banco de dados, porém ele não me trás o resultado alguém pode me ajudar? <form name="enter" method="post" action="" enctype="multipart/form-data"> Inserir código: <input type="text" name="pesquisa" /><input type="submit" name="mandar" value="Buscar" /> </form> <?if(isset($_POST['mandar'])){ $pesquisa = $_POST['login'];$sql = "SELECT * FROM usuario WHERE login LIKE'%pesquisa%'";$limite = mysql_query("$sql");while ($sql = mysql_fetch_array ($limite) ) { Quote Link to post Share on other sites
0 lowys 0 Posted September 10, 2015 Report Share Posted September 10, 2015 (edited) Troque $_POST['login'] por $_POST['pesquisa'] Edited September 10, 2015 by lowys Quote Link to post Share on other sites
0 mekker 0 Posted September 10, 2015 Author Report Share Posted September 10, 2015 Ele volta com o primeiro da tabela não com o que foi digitado no campo de pesquisa!! <h20>Lista de Usuários do Sistema</h20> <? require ("conn.php"); ?><form name="enter" method="post" action="" enctype="multipart/form-data"> Inserir código: <input type="text" name="pesquisa" /><input type="submit" name="mandar" value="Buscar" /> </form> <?if(isset($_POST['mandar'])){$login = $_POST['pesquisa'];$sql = "SELECT * FROM usuario WHERE login LIKE'%".$pesquisa."%'";$limite = mysql_query("$sql");while ($sql = mysql_fetch_array ($limite) ) {$id = $sql['id'];$nome = $sql['nome'];$login = $sql['login'];} ?> </p> <table width="700" border="0" cellspacing="0" cellpadding="0"> <tbody> <tr> <td>Nome:<? echo $sql = "$nome";?></td></tr></tbody></table><? } ?> Quote Link to post Share on other sites
0 lowys 0 Posted September 11, 2015 Report Share Posted September 11, 2015 Use mysqli ou pdo Quote Link to post Share on other sites
Question
mekker 0
Estou tentando fazer uma consulta de usuário do banco de dados, porém ele não me trás o resultado alguém pode me ajudar?
<form name="enter" method="post" action="" enctype="multipart/form-data">
Inserir código: <input type="text" name="pesquisa" />
<input type="submit" name="mandar" value="Buscar" />
</form>
<?
if(isset($_POST['mandar'])){
$pesquisa = $_POST['login'];
$sql = "SELECT * FROM usuario WHERE login LIKE'%pesquisa%'";
$limite = mysql_query("$sql");
while ($sql = mysql_fetch_array ($limite) ) {
Link to post
Share on other sites
3 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.