Forum Moderators: coopster
i'll be honest here, i posted this a while back on another forum and i realise what i am trying to do will have normalisation issues, but i was curious if there is a quick n dirty solution i could implement, while i get my head round updating ,inserting multiple checkboxes into various tables the right way.
the idea is that everytime say for example a news item is added in the cms, the admin will check 'check boxes' of the categories that story falls into
[] backpain
[] fitness training
[] alternative therapy etc etc
at the moment i am storing the array as a comma seperated array in a column called keywords (bad i know)
so far all well and good i retrieve the data as follows
do {
$nkw = explode(',',$row_news['keywords']);
if (($row_news['article_id']) ==(in_array($row_article['keywords'], $nkw))){
echo '<li><a href="mat_news.php?article_id=' . $row_news['article_id'] . '" target="_self" title="'.$row_news['headline'] .'">' . $row_news['headline'] . '</a></li>';
}
} while ($row_news = mysql_fetch_assoc($news2));
this works fine if there is an exact match from the checked checkboxes, ie both articles have just backpain checked
but i want to relate the articles even if there is just a single match from one of the checkboxes,
ie article one has back pain and fitness training checked
article 2 has just backpain checked
any help much appreciated
mat
the explode makes the array into 13 rather than 1 and 3, could this make sense i wonder?