Jump to content

mikefrederick

Members
  • Posts

    247
  • Joined

  • Last visited

    Never

Everything 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. Actually that wasn't the only problem, just fixed some of the errors, some words still aren't being highlighted correctly.
  3. It actually turns out that what was not only slowing the script down a lot but causing those errors was the preg_replace...why? What did I do wrong?
  4. 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."|"; }
  5. how do I do this then? I mean you can use an array for the value you want to replace, why not for the value you are replacing it with
  6. why does this not work? it replaces each $x in the array with the actual word array rather than the original word. $bar = $_GET['letters']; $x=explode(" ",$bar); $a=str_replace($x,"<span style='color: #000066; font-weight: 600'>" . $x . "</span>",$t);
  7. 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.
  8. 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).
  9. That's not working out for me. Is there a better way? I don't see what is wrong with what you wrote but all well
  10. 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."|"; }
  11. 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?
  12. I typically do $a=mysql_query("select * from...where...") and then use if(mysql_num_rows($a)=='0') { insert } else { update }
  13. Okay, if the radio is playing on www.shoutcast.com you want a green light?
  14. 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
  15. You have to show code. PHP is server-side, it can't update without page loading/reloading. But javascript might work if you show what you need to do.
  16. Yeah I mean there's no reason why you can't just store them in a thumbs folder.
  17. <SCRIPT language="JavaScript1.2"> function poponload() { testwindow= window.open ("<?php echo $link; ?>", "mywindow", "location=1,status=1,scrollbars=1,width=500,height=300"); testwindow.moveTo(0,0); }
  18. just make the link from the image to a php page that runs the delete function. click image and: <?php mysql_query("delete from...."); header("Location:theformemailpage.php"); ?>
  19. Hard to tell what you are doing, but for whatever file you are dealing with $_SERVER['PHP_SELF'] is relative to the document root, so if I understand correctly href="../thumbs/' . $_SERVER['PHP_SELF'] . ...
×
×
  • 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.