Jump to content

agh help (strings)


mikefrederick

Recommended Posts

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).

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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