PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 30th, 2006, 02:57 PM
suggy suggy is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 211 suggy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 23 h 12 m 51 sec
Reputation Power: 5
Search for usernames. show image if exact match problem

hello

i have got a user search facility on my website.

i use something like this to search the users input agains the database

PHP Code:
 $q "select * from class_members where username like '%$_GET[member]%' order by 'RegDate' limit $Start, $ByPage"


Basically this is searching for all the users which are similar to the input.

i am wanting to show an image right next to the exact match

i have this working however i have one proble. It will only show the image if the user input is exactally the way the username is stored in the database.. for example: my username is Suggy in the database. If i search suggy it wont show the image even though the spelling is correct. But as soon as you change the s to a caps S it will work...

Is there any way around this please?

The code i am using is as follows:

PHP Code:
if(!empty($_GET[Start]))
{
    
$Start $_GET[Start];
}
else
{
    
$Start '0';
}

$ByPage '5';

//get the member's assets, show them in a table (list), so the member will be able to edit or delete them
$q "select * from class_members where username like '%$_GET[member]%' order by 'RegDate' limit $Start, $ByPage";
$r mysql_query($q) or die(mysql_error());
$qnav "select * from class_members where username like '%$_GET[member]%' order by 'RegDate'";

if(
mysql_num_rows($r) > '0')
{
$similar .= "<table align=center width=500 cellspacing=1>\n";
$similar .= "<tr style=\"background-color:#C4ECFF; color:black; font-family:verdana; font-size:11; font-weight:bold\">\n\t<td align=center width=300>username</td>\n\t<td align=center width=200>Registered Since:</td>\n\t<td align=center width=200>Contact Member:</td>\n</tr>\n\n";

    
$col "white";

    while(
$amysql_fetch_array($r))
    {
        if(
$col == "white")
        {
            
$col "#FFFFE1";
        }
        else
        {
            
$col "white";
        }
    
$reg1 date('d-M-Y'$a[RegDate]);
                    if(
$a['username'] == $_GET[member]) {$exact "<img src=images/icon_star_red.gif>";} else {$exact ="";}

        
$similar .= "<tr bgcolor=$col>\n\t<td>$exact<a class=BlackLink href=\"contactmem.php?mid=$a[MemberID]\">$a[username]</a>";

        if (
$a[is_saled]!="1"){
            
$similar .= "<td align=center> $reg1\n\t</td><td align=center><a  href=\"contactmem.php?mid=$a[MemberID]\"><img src=images/iconMail_UnRead_16.gif border=0></a>\n\t</td>\n</tr>\n\n";
        } else {
            
$similar .= "</td>\n\t<td align=center>&nbsp;</td>\n</tr>\n\n";
        }
    }

    
$similar .= "</table>\n";}
    

    if (
mysql_num_rows($r)<'1') {
    
$similar="No Matching members please try another search";
}

        
$rnav mysql_query($qnav) or die(mysql_error());
        
$rows mysql_num_rows($rnav);

            if(
$rows $ByPage)
            {
                
$Navigation .=  "<br><table align=center width=580>";
                
$Navigation .= "<td align=center><font face=verdana size=4> | ";

                
$pages ceil($rows/$ByPage);

                for(
$i 0$i <= ($pages); $i++)
                {
                    
$PageStart $ByPage*$i;
    
                    
$i2 $i 1;
    
                    if(
$PageStart == $Start)
                    {
                        
$links[] = " <span class=RedLink>$i2</span>\n\t ";
                    }
                    elseif(
$PageStart $rows)
                    {
                        
$links[] = " <a class=BlackLink href=\"curad.php?Start=$PageStart\">$i2</a>\n\t ";    
                    }
                }

                
$links2 implode(" | "$links);
        
                
$Navigation .= $links2;

                
$Navigation .= "| </td>";

                
$Navigation .= "</table><br>\n";

            } 

Reply With Quote
  #2  
Old December 30th, 2006, 04:18 PM
Sepodati's Avatar
Sepodati Sepodati is offline
Banned
Dev Shed God 19th Plane (14000 - 14499 posts)
 
Join Date: Dec 1999
Location: Kentucky
Posts: 14,429 Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)Sepodati User rank is General 23rd Grade (Above 100000 Reputation Level)  Folding Points: 97169 Folding Title: Advanced FolderFolding Points: 97169 Folding Title: Advanced FolderFolding Points: 97169 Folding Title: Advanced FolderFolding Points: 97169 Folding Title: Advanced FolderFolding Points: 97169 Folding Title: Advanced Folder
Time spent in forums: 3 Months 1 Day 17 h 28 m 7 sec
Reputation Power: 2546
Send a message via ICQ to Sepodati Send a message via Yahoo to Sepodati
PHP Code:
if($a['username'] == $_GET[member]) 
PHP is case sensitive. So your comparison is only going to be TRUE is the cases match. You can a) convert both to all uppercase or all lowercase and then do the comparison or b) use the strcasecmp() function to do the comparison.

---John Holmes...

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > Search for usernames. show image if exact match problem


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



 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

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





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