MySQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMySQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old September 19th, 2003, 04:28 AM
sylvano sylvano is offline
sylvano3
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Location: Mannheim
Posts: 12 sylvano User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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 *

Reply With Quote
  #2  
Old September 19th, 2003, 11:40 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 8
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%"

Reply With Quote
  #3  
Old September 22nd, 2003, 06:17 AM
sylvano sylvano is offline
sylvano3
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Location: Mannheim
Posts: 12 sylvano User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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)

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMySQL Development > search in php + mysql


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT