Select value = 0 is not working

Hello,

I am trying to make a photogallery with categories.
I tried to make a function to set a image to category 0 (meaning no category)
But when I press submit it shows no result, aka nothing is being done.

[php]if(isset($_GET[‘a’]))
{
$a = $_GET[‘a’];
$Contains = 0;
$CatID = 0;
if($a == ‘assign’)
{
$submit = $_POST[‘submit’];
$Category = $_POST[‘Category’];
if($submit)
{
foreach($_POST[‘check_list’] as $check) {
$query = mysql_query(“SELECT * FROM Images WHERE ImgID = $check”);
while($row = mysql_fetch_assoc($query))
{
$CatID = $row[‘ImgCat’];
if(isset($Category)){
mysql_query(“UPDATE Images SET ImgCat = $Category WHERE ImgID = $check”);
}else{
mysql_query(“UPDATE Images SET ImgCat = 0 WHERE ImgID = $check”);
}
}
//Update the new Amount of Images in the old category
$query = mysql_query(“SELECT * FROM Categories WHERE CatID = ‘$CatID’”);
while($row = mysql_fetch_assoc($query))
{
$Contains = $row[‘AmountImgs’];
}
$query = mysql_query(“SELECT * FROM Categories WHERE CatID = ‘$CatID’”);
if(mysql_num_rows($query) == 1)
{
$Contains = $Contains - 1;
mysql_query(“UPDATE Categories SET AmountImgs = $Contains WHERE CatID = ‘$CatID’”);
}
//Update the new Amount of Images in the new category
if(isset($Category)){
$query = mysql_query(“SELECT * FROM Categories WHERE CatID = ‘$Category’”);
while($row = mysql_fetch_assoc($query))
{
$Contains = $row[‘AmountImgs’];
}
$query = mysql_query(“SELECT * FROM Categories WHERE CatID = ‘$Category’”);
if(mysql_num_rows($query) == 1)
{
$Contains = $Contains + 1;
mysql_query(“UPDATE Categories SET AmountImgs = $Contains WHERE CatID = ‘$Category’”);
}
}
}
echo '

U heeft succesvol de categorie van de geselecteerde foto’s veranderd!
U wordt binnen 5 seconde doorgestuurd!


‘;
header(‘Refresh: 5; URL=?p=lijst’);
}
}
}
else
{
echo’<form id=“theForm” method=“post” action="?p=lijst&a=asign"">









';
$query = mysql_query(“SELECT * FROM Images”);
while($row = mysql_fetch_assoc($query))
{
$ImgPath = $row[‘ImgPath’];
$ImgName = $row[‘ImgName’];
$ImgID = $row[‘ImgID’];
$ImgCat = $row[‘ImgCat’];
			$query2 = mysql_query("SELECT * FROM Categories WHERE CatID = '$ImgCat'");
			while($row = mysql_fetch_array($query2)) {
				$CategoryName = $row['CategoryName'];
			}
			echo '
			<tr>
			<td><input type="checkbox" name="check_list[]" value="'.$ImgID.'"></td>
			<td>'.$ImgName.'</td>
			<td><a href="'.$ImgPath.'" target="_blank">'.$ImgPath.'</a></td>
			<td>'.$CategoryName.'</td>
			</tr>';
			
		}
		echo '</tbody>
        </table>
		<br /><label for="Category">Verander naar categorie:</label>
		<div class="input-append">
		<select name="Category">
		<option value="">Geen Categorie</option>';
			$query = mysql_query("SELECT * FROM Categories WHERE CatID > 0");
			while($row = mysql_fetch_assoc($query)) //loop thought table that we select in mysql_query 
			{
				$CategoryName = $row['CategoryName'];
				$CatID = $row['CatID'];
				$Contains = $row['AmountImgs'];
				echo '<option value="'.$CatID.'">'.$CategoryName.' ('.$Contains.' images)</option>';
			}
		echo '</select>
		  <input type="submit" class="btn" name="submit" value="Verander Categorie"/>
		</div>
		</form>';
	}
	echo '</div>';[/php]
Fotonaam Foto URL Categorie

You are surrounding variables in single quotes. Have you echoed you problem statements to see what is being requested?

Sponsor our Newsletter | Privacy Policy | Terms of Service