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 wordt binnen 5 seconde doorgestuurd!
‘;
header(‘Refresh: 5; URL=?p=lijst’);
}
}
}
else
{
echo’<form id=“theForm” method=“post” action="?p=lijst&a=asign"">
Fotonaam | Foto URL | Categorie |
---|