My loop below finds the first instance of “selected” and then no more. The output should say “selected” for FARM and COUNTRY but only farm comes back. Sample output is below. I know it’s just the order I have the WHILE, FOR and IF statements but I can’t figure it out.
Partial sample output:
category NOT selected “SKY”
category selected “FARM”
category NOT selected “CITY”
category NOT selected “TOWN”
category NOT selected “COUNTRY”
The value of $row is 100 and $wordChunks is 2.
$wordChunks = explode(" | ", $categoryquery1['companycategory']);
$sql = "SELECT category_name FROM company_categories " . " ORDER BY category_name";
$rs = mysql_query($sql);for($i = 0; $i < count($wordChunks); $i++)
{
while($row = mysql_data_seek($rs, 0)
{
if ($wordChunks[$i] == $row['category_name'])
{
echo "category selected \"".$row['category_name']."\"<br />";
}
else {
echo "category NOT selected \"".$row['category_name']."\"<br />";
}
}
}
Check this out,
Please dont use
mysql_*extensions, usemysqli_*instead.