dan17 Posted March 2, 2009 Share Posted March 2, 2009 Hi, I've been banging my head all day and I can't figure it out. $find = strip_tags($find); $find = trim($find); $find = strtoupper($find); $data = mysql_query("SELECT * FROM profiles"); while ($ss1 = mysql_fetch_array( $data )) {$ss3=$ss1['keywords']; $ss4=(explode(",",$ss3)); for ($x=0; $x<count($ss4); $x++){ $ss5=strip_tags($ss4[$x]); $ss5=trim($ss4[$x]); $ss5=strtoupper($ss4[$x]); if ($find==$ss5){ $profile=$ss1['name']; $pro_lvl=$ss1['prolvl']; $query=("insert into search(profile,pro_lvl,id) values ('$profile','$pro_lvl','$id')"); $result = mysql_query($query); }}} It's supposed to insert all matches into table, but it only does if the first object ([0]) matches. If it's [3] loop doesn't see it. Please help ASAP. Link to comment https://forums.phpfreaks.com/topic/147622-solved-loop-just-ignores-the-string/ Share on other sites More sharing options...
br0ken Posted March 2, 2009 Share Posted March 2, 2009 You'll find people help you a lot more if your code is indented correctly and all of your braces line up. While I don't know what your problem is without seeing some sample data, I've added a two echo commands in so that you can see the value in find and the value it is being compared against ($ss5). Run this code and see the values printed and maybe that will shed some light on your problem. $find = strip_tags($find); $find = trim($find); $find = strtoupper($find); $data = mysql_query("SELECT * FROM profiles"); while ($ss1 = mysql_fetch_array( $data )) { $ss3=$ss1['keywords']; $ss4=(explode(",",$ss3)); for ($x=0; $x<count($ss4); $x++) { $ss5=strip_tags($ss4[$x]); $ss5=trim($ss4[$x]); $ss5=strtoupper($ss4[$x]); echo $find."<br>"; echo $ss5."<br><br>"; if ($find==$ss5) { $profile=$ss1['name']; $pro_lvl=$ss1['prolvl']; $query=("insert into search(profile,pro_lvl,id) values ('$profile','$pro_lvl','$id')"); $result = mysql_query($query); } } } Link to comment https://forums.phpfreaks.com/topic/147622-solved-loop-just-ignores-the-string/#findComment-774955 Share on other sites More sharing options...
dan17 Posted March 2, 2009 Author Share Posted March 2, 2009 Thank you very much. This issue has just been resolved - filtering array elements wasn't progressing, just beatin same [$x]. Oh this stupid little things that eat up hours sometimes! Link to comment https://forums.phpfreaks.com/topic/147622-solved-loop-just-ignores-the-string/#findComment-774966 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.