Hi all,
I've got some data stored as MySQL "SET" datatype...column name Extras.
The possible values as defined by the datatype are:
1, 2, 3, 4, 5, through 19.
Here's my code to display some results from an (*) all query on my test db. Results are in an array with num_rows = $cntr.
$arrayExtras = array ("Extra Desc 1",
"Extra Desc2",
"Extra Desc 3",
"Extra Desc 4",
"Extra Desc 5",
.... continues to 19
"Extra Desc 19");
for ($x=0;$x<$cntr;$x++) {
echo "$var1[$x]<br>";
echo "$var2[$x]<br>";
echo "$var3[$x]<br>";
echo "$var4[$x]<br>";
$showExtras = "";
for ($b=0;$b<count($arrayExtras);$b++) {
if (preg_match("/$b/", "$extras[$x]")) {
if ($showExtras != "") {
$showExtras .= ", ";
}
$showExtras .= "$arrayExtras[$b]";
}
}
echo "<b>Extras:</b> $showExtras<br>";
}
It works for single digit members of the SET....such as if the row contains 2,4,9 in the database....it will be displayed as Extras Desc 2, Extras Desc 4, Extras Desc 9.
The problem is, if a row contains "19" for the SET type column on Extras....the code above will display Extras Desc 1, Extras Desc 9, Extras Desc 19. I want it to only display the exact match...Extras Desc 19.
Any ideas on how to get the exact match for each inumeration..if it's there??
Thanks!