hello
i am designing a simple cms which will be used to administrate newspostings and such. already built the part that allows for new entries and deleting/editing them, that was no problem.
the part that's tricky is setting the news being active or inactive. i've added a field in the mysql database named 'news_active' of which the value can be 0 or 1, being inactive or active respectively. this works ok when someone views the news.
i'm using checkboxes to determine if news is active or not, and taking the value from the database and setting the corresponding boxes to be checked or not.
the problem is, i want all the newsitems to be updated active or inactive at the same time when a user clicks a link on the page. i hope this makes any sense:
[some parts in the code are in dutch for display purposes]
this is the part which takes the data from the database and displays it, draws the boxes etc.
$selectallnews_query = "SELECT news_id, news_title, news_date, news_active, user_id FROM news ORDER BY news_date DESC";
$allnews_result = mysql_query($selectallnews_query);
$allnews_rows = mysql_fetch_assoc($allnews_result);
$content .= '<form name="news_selector" method=post action="">
<table>';
//'.$allnews_rows['news_active'].'
do {
$content .= '<tr>
<td>'.$allnews_rows['news_title'].'</td>
<td>'.$allnews_rows['news_date'].'</td>
<td><input type="checkbox" name="active['.$allnews_rows['news_id'].']" value=';
if ($allnews_rows['news_active'] == '1')
{
$content .= '"on" CHECKED></td>';
}
else
{
$content .= '"off"></td>';
}
$content .= '<td>'.$allnews_rows['user_id'].'</td>
<td><a href="index.php?page=101&action=edit&newsid='.$allnews_rows['news_id'].'">Bewerken</a></td>
<td><a href="index.php?page=101&action=delete&newsid='.$allnews_rows['news_id'].'">Verwijderen</a></td>
</tr>
';
}
while ($allnews_rows = mysql_fetch_assoc($allnews_result));
$content .= '<tr>
<td></td>
<td></td>
<td><a href="index.php?page=101&action=active">Wijzig Actief</a></td>
<td></td>
<td><a href="index.php?page=101&action=new">Voeg Nieuws Toe</a></td>
<td></td>
<tr>
</table></form>
';
the part which is called when user clicks link "Wijzig Actief" (change active)
if (isset($_REQUEST['action']))
{
if ($_REQUEST['action'] == 'active')
{
// do some queries and such i don't know
}
first code segment: this part of page loads when all checks for the 'action' variable fail, and loads the list of all newsitems
second code segment: this part is called when the user clicks "Wijzig Actief" (change active)
OK!! now what do i want it to do? i want it to be so that when the user clicks the link "Wijzig Actief" it gets all values from the checkboxes, and updates them in the database accordingly.
the problem is because the link is static, i can't put all the data in the header and then update using a simple loop. is there any way this can be done??