I have a loop where it query's mysql for a search but the search will change by the end of the query. What i found out with my coding is which i did not now is that i can't reassign a variable to a new search query, or not correctly anyways.
I have added echo's to see what it's doing.
Lets say John is assigned to $preg_split
What i am trying to do is to match a character with a database if one the first characters in the database for example J matches then assign the second character from $pre_split which is o so $char would be jo
So the variable $char in the beginning should be updated with jo
Instead for some reason which i'm sure that i just did not write my code correct is that it echo's o an not jo..
So i'm a bit puzzled why its the second character and not the first.
$NG_implode = implode("", $preg_split);
$NG_split = str_split($NG_implode, 1);
$i = '0';
$ia = '1';
$ib = '0';
$ic = '1';
$char = $NG_split[$ib];
foreach ($NG_split as $char)
{
$NG_select_like = "SELECT word FROM checklist_filter WHERE word LIKE '".$char."%'";
$NG_query = mysql_query($NG_select_like) or die(mysql_error());
$NG_row = mysql_fetch_row($NG_query);
$chars = str_split($char, 1);
$row = str_split($NG_row[0], 1);
if ($chars[$i] == $row[$i])
{
$char = $char.$NG_split[$ia];
$ia++;
$i++;
if ($char == $NG_row[0]){break;}
}else{$ib++; $char = $NG_split[$ib];}
}