Need to pass multiple values to DB through a form
Posted: Tue Feb 03, 2009 3:49 am
The thing is I am retrieving information from a database, it makes a list of all INACTIVE links that needs to be accepted by a admin. Down at the foreach its a very confusing code, its just me testing things out. I need a push in the right direction, dont wanna have more problems with this. Well anyways I want the links to be accepted through a checkbox. I want it to be able to pass multiple links that I want to make active. I only know a way of making 1 active. Anyone who can help me out?
Code: Select all
<?php
$query = 'SELECT * FROM url_list WHERE url_status = 0 ORDER BY url_kategori ASC';
$result = mysql_query($query);
confirm_query($result);
echo "<form method='post' action=''>";
while($url = mysql_fetch_array($result))
{
echo "<h3>Kategori: " . $url['url_kategori'] . "</h3>";
echo "<p>Titel: " . $url['url_titel'] . "</p>";
echo "<a href=" . $url['url_url'] . ">" . $url['url_url'] . "</a><br />";
echo "<p>Beskrivning: " . $url['url_beskrivning'] . "</p>";
echo "<label>Godkänn länk</label><input type=\"checkbox\" name=" . $url['url_id'] . " value='1' /><br />";
}
echo "<input type=\"submit\" name=\"updateurl\" />";
echo "</form>";
if(isset($_POST['updateurl']))
{
foreach($url['url_id'] as $id)
{
$query = "UPDATE SET url_status = " . $_POST['$url['url_id']'] . " WHERE url_id = {$id}";
$result = mysql_query($query);
confirm_query($result);
}
}
?>