
December 30th, 2006, 02:57 PM
|
|
Contributing User
|
|
Join Date: Jul 2004
Posts: 211
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($a= mysql_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> </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";
}
|