|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
search in php + mysql
Hi all :-)
i want to make a PHP search function in to the mysql database. i want to search all users of my webfem application by username so that wenn i give: only "us" (instead username) i become all user wich the name beging with "us". ok i hope it's clear for u. do any one has some idea? * Edit: Please post in the appropriate forums * |
|
#2
|
||||
|
||||
|
From what i understand, you're looking for a query to search your users table for all user names that begin with us?
If so, try this query: SELECT * FROM users WHERE username LIKE "us%" |
|
#3
|
|||
|
|||
|
search in php + mysql
thank you for u're help ,
i've already found a solution for my problem via a php script like this: <?php function search_User_by_name($Username="") { $LENGTH= strlen($Username); $db=new webfem_db;//instantiate the database class ,phplib $query = $db->query("SELECT username ,perms ,grup FROM auth_user ") or die($display->my_error('<p align="center">Error by select !<br> <a href="search_user.php">return</a></big></p>')); while($result = mysql_fetch_array($query)) { $results[]=$result; } // var_dump($results);echo "<br>"; // var_dump($cut_result); for($i=0; $i<count($results); $i++) { $cut_result[]= substr($results[$i]["username"], 0, $LENGTH); // cut the first Strlen(number) of all username if(strcasecmp($cut_result[$i], $Username)==0) //compare them { $end_result[]= $results[$i]; //store all user infos if username begin like $Username } } return $end_result; //return reslut } ?> and its works very find. ok bye sylvain Ndjeukoua From cameroorn (live in Germany - Mannheim) |
![]() |
| Viewing: Dev Articles Community Forums > Databases > MySQL Development > search in php + mysql |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|