Jump to content

PHP Search


Go to solution Solved by requinix,

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,

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

  • Solution
if the person is searching for a user {
grab all the users that match that search, with or without pagination
} else {
grab all the users, with or without pagination
}

display those users
Edited by requinix
Link to comment
https://forums.phpfreaks.com/topic/283873-php-search/#findComment-1458165
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.