Posted: Sun Jul 23, 2006 5:57 pm
for ($i = 0; $i < $searchtermscount; $++)
should be
for ($i = 0; $i < $searchtermscount; $i++)
should be
for ($i = 0; $i < $searchtermscount; $i++)
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Code: Select all
<?php
/**
* Replace the terms in this array with the terms inside the comments you want to remove
*/
$searchterms = array('pharmacy', 'snots', 'booty', 'stinkbug', 'snaggletooth', 'footsmell', 'buttscratch', 'stupiduserentry');
$sql = "UPDATE `mos_akocomment` SET `comment` = '' WHERE 1=1";
foreach($searchterms as $key => $value) {
$sql .= " OR `comment` LIKE '%$value%'";
}
echo $sql;
?>Code: Select all
<?php
/**
* Replace the terms in this array with the terms inside the comments you want to remove
*/
$searchterms = array('pharmacy', 'snots', 'booty', 'stinkbug', 'snaggletooth', 'footsmell', 'buttscratch', 'stupiduserentry');
$sql = "UPDATE `mos_akocomment` SET `comment` = '' WHERE 1=1";
foreach($searchterms as $key => $value) {
$sql .= " OR `comment` LIKE '%{$value}%'";
}
echo $sql;
?>Code: Select all
<?php
/**
* Replace the terms in this array with the terms inside the comments you want to remove
*/
$searchterms = array('pharmacy', 'snots', 'booty', 'stinkbug', 'snaggletooth', 'footsmell', 'buttscratch', 'stupiduserentry');
$conditions = array();
foreach($searchterms as $value)
$conditions[] = "`comment` LIKE '%{$value}%'";
$sql = "UPDATE `mos_akocomment` SET `comment` = '' WHERE ".implode(" OR ", $conditions);
//
// connect to the db server and select db
//
$result = mysql_query($sql);
?>Code: Select all
<?php
/**
* Replace the terms in this array with the terms inside the comments you want to remove
*/
$searchterms = array('pharmacy', 'snots', 'booty', 'stinkbug', 'snaggletooth', 'footsmell', 'buttscratch', 'stupiduserentry');
$conditions = array();
foreach($searchterms as $value)
$conditions[] = "`comment` LIKE '%{$value}%'";
$sql = "DELETE FROM `mos_akocomment` WHERE ".implode(" OR ", $conditions);
//
// connect to the db server and select db
//
$result = mysql_query($sql);
?>