Jump to content

PHP Search


Nick19

Recommended Posts

Okay so i have created a php search script that selects the users user-name from the database when you search for it, but i want it to list all users and want the search box at the top, when a user is searched i want all the users to hide and only want the one user searched for to display..

 

eg..

 

 <!-- Searchbox --> < when a user is searched for eg user 1 i want user 2 and 3 to go and only user 1 to stay.

 

<!-- List all users -->

 

user1

user2

user3

 

<-- End -->

 

the code i have...

 

test.php file

<?php
session_start();
require "config.php";

if (isset($_POST ['name']))
{
$result=@mysql_query("SELECT * FROM users WHERE user='" . $_POST['name'] . "'");
$row =@mysql_fetch_array($result);
echo $row['user']; 
echo "<br>";
}
?>
<table>
Find a User:
<form name="form1" method="post" action="test.php">
<input name="name" type="text" id="name" />
<input type="submit" name="Submit2" value="Find" />
</form>
</table>	

any suggestions on how to do this?

thanks,

Link to comment
https://forums.phpfreaks.com/topic/283873-php-search/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.