hi,
i have a table of products (about 4500). the title field has the brand and the title of the product. I want to step through the titles and check against an array of brand names. If there is a match remove the brand from the title and then update the title without the brand in it.
currently what i have only does the first record. if i use a limit, only the first of the limit works, and if i try to se a count and step throughit that way, it only does one also.
here is what i have:
$brand_array = array();
#####################
$sqlB = "SELECT name FROM brands ORDER by 'name' ASC";
$resultB = mysql_query($sql😎;
while ($rowB = mysql_fetch_array($result😎)
{
$name = $rowB["name"];
$brand_array[] = $name;
}
#####################
$sql = "SELECT id,title FROM products2 ORDER by id ASC";
$result = mysql_query($sql);
while ($row = mysql_fetch_array($result))
{
$id = $row["id"];
$title = $row["title"];
##############
while ($rowA = each($brand_array))
{
$a_string = $rowA["value"];
$s_check = strpos($title,$a_string);
//this is just to visually see it working \/
echo $title;
echo "<br>\n";
echo $a_string;
echo "<br>\n";
//this is just to visually see it working /\
if ($s_check === 0)
{
$tmp_str = str_replace($a_string,"",$title);
$titleD = trim($tmp_str);
echo $titleD;
$sqlD = "update products2 SET title = '$titleD' where id = '$id'";
$sql_result_brandD = mysql_query($sqlD) or die ("count update title!");
}
}
##############
}
##################
echo "done";
thanks.