preg_match
Posted: Tue May 19, 2009 8:22 pm
Ok so the following code works, but I need to put information from my mySQL database into $var1. The information is seperated by commas in the different columns of my database (ex: col_1 = object1, object2, object3). I need to basically "echo" a columns contents into $var1. Is this possible? Hopefully that makes sense
Code: Select all
$result = mysql_query("SELECT * FROM table_name");
$var1 = "need databse information to go here";
while($row=mysql_fetch_array($result))
{
$rows=explode(", ", $row['table_row']);
foreach($rows as $table_row)
{
if (preg_match("/\b$table_row\b/i", "$var1")) {
echo $table_row.'RED HIGHLIGHT<BR> ';
}else {
echo $table_row.'<BR> ';
}
}
}