Hi
I am sure this is a simple question to most of you, but is causing me real problems.
I am creating a kinda news section for my web site using PHP and MYSQL, and want to Categorise every news story to be one or more types of news.
I am able to enter news stories into the database OK, but am having problems with the type of news issue.
I am using checkboxes on my submit form. If I check one check box, I want one record inserted into a typeofnews table, but if two check boxes are checked I want two records added to that table. (The typeofnews table is a joining table between a story table and a type table)
I looked at some of the other posts including the one at http://www.sitepointforums.com/showt...hreadid=25691, but although I thought this was helping me I can't get it to work.
I wonder if someone could take a look at this code and point me in the right direction.
ThanksPHP Code:if ("SUBMIT" == $submitstory) {
foreach($newstype as $val) {
$sql2 = ("INSERT INTO typeofnews (type_ID, news_ID)
VALUES ('$val', '$storyid')");
if (mysql_query($sql2)) {
echo("<CENTER>The type of story has been added.</CENTER>");
} else {
echo("<P>Error adding type of news: " .
mysql_error() . "</P>");
}
}
)
Keith






Bookmarks