i have a database with more than 20.000 posts on it. most of the posts have a signature:
like this one :
If in my dreams is the only
place i can hould u !
Then i want to sleep forever !!
Me:bb:272F9F64
so i want to print all the posts insde my database who contain signatures like (Me:PIN:272F9F64 )
all those signatures are starting with ( PIN: or PIN ) and they are 8 digits numbers and alphabit.
i used this code to print them but it is not working
$get_tit = $db->query("select id,name from brd limit 1000");
while($th=$db->fetch($get_tit)){
if (preg_match("/PIN:[0-9a-zA-Z]+/", $th['name'])) {
echo $th['name']."<br>";
}
}
UPDATED **
this code for loop throw the database and delete any signature inside the post
$get_tit = $db->query("SELECT id, name FROM brd LIMIT 1000");
echo 'Results Found :'.mysql_num_rows($get_tit).'<br /><br />';
while($th=$db->fetch($get_tit)){
$result = mysql_query("UPDATE brd SET name=LEFT(name,LENGTH(name)-12) WHERE name REGEXP 'PIN:[0-9a-zA-Z]{8}$' and id='$th[id]'") or die(mysql_error());
}
but it is not working the signature still there
any help Guys
Bbway
This can be done really easily within MySQL:
Are you sure
nameis the field that has the post in it, though? I don’t know how you have your database designed, but personally I’d havenameas the name of the user, andcontentas the content of the post. Make sure you have the right field name.