Jump to content

mikefrederick

Members
  • Posts

    247
  • Joined

  • Last visited

    Never

Posts posted by mikefrederick

  1. here is the code I am using now, a little better but still not much, and in addition, sometimes the <span> will show up in the search box. example: type in "University Wisconsin Madison t". whyy

     

    if(isset($_GET['getCountriesByLetters']) && isset($_GET['letters'])){
    $bar = $_GET['letters'];
    $replace[0]="-";
    $replace[1]="the ";
    $replaces[1]="";
    $replaces[0]="";
    
    $bar=str_replace($replace,$replaces,$bar);
    $replacee[0]=" of ";
    $replacee[1]=" in ";
    $replacesz[1]=" ";
    $replacess[0]=" ";
    $bar=str_replace($replacee,$replacess,$bar);
    
    $x=explode(" ",$bar);
    $z="<span style='color: #000066; font-weight: 600'>" . implode(" </span><span style='color: #000066; font-weight: 600'>",$x) . "</span>";
    $search = "WHERE name LIKE '%" . implode("%' and name LIKE '%", $x) . "%' ";
    $res=mysql_query("select * from schools " . $search . " order by name limit 7");
    while($inf = mysql_fetch_array($res)){
    $t=$inf["name"];
    foreach(explode(" ",$bar) as $x)
    $t= str_replace($x,"<span style='color:#000066'>" . $x . "</span>",$t);
    echo $inf["id"]."###".$t."|"; 
     }	
    

  2. Check out scripts.loado.com/friendsearcher.php.

     

    Type in University Wisconsin Madison (slow enough to let the search results populate while typing - slow server). After you type a space and then M for Madison, Wisconsin typically becomes unhighlighted.

    The search box works, but not correctly all of the time. What you are searching for should be highlighted in the search results that show up, but sometimes words do not get highlighted until the entire word has been searched for, and sometimes they do not get highlighted at all, and sometimes they become unhighlighted as I just said above. I think it words better in Safari than Firefox. How should I improve this script to get rid of these annoying errors?

    $bar = $_GET['letters'];
    $bar = preg_replace("/[^a-z0-9 ]/si","",$bar);
    $x=explode(" ",$bar);
    $u=explode(" ",$bar);
    $e=array($u);
    
    $z="<span style='color: #000066; font-weight: 600'>" . implode(" </span><span style='color: #000066; font-weight: 600'>",$x) . "</span>";
    $search = "WHERE name LIKE '%" . implode("%' and name LIKE '%", $x) . "%' ";
    $res=mysql_query("select * from schools " . $search . " order by name limit 7");
    
    
    while($inf = mysql_fetch_array($res)){
    $t=$inf["name"];
    
      foreach($u as $x)
        $t= str_replace($x,"<span style='color: #000066; font-weight: 600'>" . $x . "</span>",$t);
    
    	echo $inf["id"]."###".$t."|"; 
     }	

  3. someones gotta know. my problem is that I need to do str_replace to each part of the exploded array, and replace it with the same thing in a different color. but when I try to do that, it actually replaces each word with the word array.

  4. Okay, have a script I am using to search a database. It searches correctly, separating each worth with a space (" "). However, I am also trying to replace the search query with a different color, and this only works up until the first space. After that, the search still works but nothing is replaced with a different color. Thanks in advance:

     

    $bar = $_GET['letters'];
    $bar = preg_replace("/[^a-z0-9 ]/si","",$bar);
    $x=explode(" ",$bar);
    $z="<span style='color: #000066; font-weight: 600'>" . implode(" </span><span style='color: #000066; font-weight: 600'>",$x) . "</span>";
    $search = "WHERE name LIKE '%" . implode("%' and name LIKE '%", $x) . "%' ";
    $res=mysql_query("select * from schools " . $search . " order by name limit 7");
    
    
    while($inf = mysql_fetch_array($res)){
    $t=$inf["name"];
    
    $a=str_replace($bar,$z,$t);
    
    	echo $inf["id"]."###".$a."|";
     }	

     

     

    $a=str_replace($bar,$z,$t); is the function used to replace the search query (I realize how incorrect I have this setup right now, I just held down apple+z for about a half hour undoing the different ways I have tried this).

  5. I made a search script like that of facebooks friend searcher. It is at scripts.loado.com/friendsearcher.php. Only difference is facebook uses a space (" ") separator when searching strings from a database. With mine, if you type a space and continue searching it will continue to search the same string (so basically my problem is that if you have a friend named Michael Frederick and you search for Frederick Michael it will not work. Frederick, Michael, or Michael Frederick will work) . I guess after the first space, I have to select from the database where I have already selected PLUS where name like %second explode($string)%...sorry if this is confusing, I know what has to be done I have just been confusing myself on how to do it. Here is how I am selecting from the database now, and thanks for the help:

     

     

    $x = $_GET['x'];
    $x = preg_replace("/[^a-z0-9 ]/si","",$x);
    $res = mysql_query("select * from schools where name like '%".$x."%' order by name limit 7") or die(mysql_error());
    while($inf = mysql_fetch_array($res)){
    $t=$inf["name"];
    $a=str_replace($x,"<span style='color: #000066; font-weight: 500'>$x</span>",$t);
    	echo $inf["id"]."###".$a."|";
    }	

     

     

     

     

  6. When you use facebook's friend search, there is no time loading friends that match the search criteria in between pressing keys. I tried to make something like it at notesite.truegraphic.com. Search for University or something. I use AJAX and PHP with a query like this:

     

    mysql_query("select * from schools where name like '%".$name."%' order by name limit 7") or die(mysql_error());

     

     

    But everytime you press a key all of the schools go away and take too long to come back. How could I cut the time down? There are 500 schools in the database, do you think it is just taking a long time to search them all?

  7. in other words, not too many people are going to be familiar with shoutcast, do you have your own script relating to shoutcast that you can show us and then the script you are talking about can be developed or do you have to go to the shoutcast site or where is this coming from

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