from all the many post that i have done before I am slowly building a dynamic upload and gallery system. What I need help on is the code that I have written to add an icon to the categories page if there is not one already in there. what I get is that it inserts a new row in teh database for just the icon and nothing it doesn't insert it into the category that I want it too, but when I removed the icon row from thr database and tried to reupload a file it still said that there is an icon already. I think that i wrote the code so it searches the whole table but thats not what I want.
here is the code that does the search which is where I think that I am having my problem
$sql = "SELECT category_icon FROM gallery_category WHERE category_id='".addslashes($photo_category_id)."'";
$results = mysql_query($sql);
$count = mysql_num_rows($results);
$icon = ($count < 1)? false : true;
here is where I insert the icon info
// Add a icon to the category
if($icon == false) {
$sql = "INSERT INTO gallery_category(category_icon) VALUES('".addslashes('tb_'.$filename)."') WHERE category_id ='".$photo_category_id."'";
mysql_query($sql);
echo "icon added <br />"; //debugging
}
else {
echo "There is an icon already<br />"; //debugging
}