david212 Posted May 20, 2009 Share Posted May 20, 2009 Hello. Im creating a search function, im getting data from MySQL. I want all found words to be written in red. Here is the code: <?php mysql_connect("localhost","root",""); mysql_select_db("my_db"); if(isset($_POST["xd"])){ $sql="SELECT * FROM nb WHERE msg LIKE \"%".$_POST["xDDDD"]."%\""; $r=mysql_query($sql); $s=mysql_num_rows($r); for($i=0;$i<$s;$i++){ $ret=mysql_result($r,$i,"msg"); echo($ret."<br>......"); } } ?> i tried in this mode, if($n=$_POST["xDDDD"]){ echo("<font color='ff0000'>".$n."</font><br>......"); } but it only shows the search word in red. Can anyone help me? Thanx Link to comment https://forums.phpfreaks.com/topic/158944-need-help/ Share on other sites More sharing options...
radi8 Posted May 20, 2009 Share Posted May 20, 2009 Well, in the if statement, you need to have 2 '=' to do the comparison, like so: <?php if($n==$_POST["xDDDD"]){ echo("<font color='ff0000'>".$n."</font><br>......"); } ?> Link to comment https://forums.phpfreaks.com/topic/158944-need-help/#findComment-838296 Share on other sites More sharing options...
david212 Posted May 21, 2009 Author Share Posted May 21, 2009 i've tried this one yesterday, but it doesn't work so. ... Link to comment https://forums.phpfreaks.com/topic/158944-need-help/#findComment-838701 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.