Page 1 of 1

[SOLVED]Select, Match and Pull from same row?

Posted: Fri Oct 28, 2005 5:08 am
by blacksnday
What I'm trying to do is convert my hard-coded preg_replace stuff
to be web-adminable, which means have the data stored in mySQL DB and
then using variables on php to pull.

The way i set it up for now is
Table= filter
Fields= word, replace

and the php would be

Code: Select all

$getWord = mysql_query("SELECT * FROM filter "); 
$checkWord = mysql_fetch_array($getWord);
$Word    = $checkWord['word'];
$Replace = $checkWord['replace'];
if ($Word  == $Word) {
	$html = preg_replace("#$Word#i", "$Replace", $html);
}else{
}
The problem with that is it will only replace the first word found.
How do I change it so it will replace anyword that matches whats in the DB?

Posted: Fri Oct 28, 2005 5:15 am
by sebs
try:

Code: Select all

while($checkWord = mysql_fetch_array($getWord))
{....}

Posted: Fri Oct 28, 2005 5:18 am
by blacksnday
sebs wrote:try:

Code: Select all

while($checkWord = mysql_fetch_array($getWord))
{....}
doh!! lol....... its late(or early) and i havent slept in about 14 hours..

thanks for the obvious :D lol

Posted: Fri Oct 28, 2005 5:23 am
by blacksnday
heh... the if else statement is useless also... i know
I just need some sleep 8O