Well funnily enough I did some testing, and it works!!!!
mySQL Setup
CREATE TABLE `davidosullivan` (
`id` int(11) NOT NULL auto_increment,
`prod_image_1` text,
`prod_image_2` text,
`prod_image_3` text,
`prod_title` text NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;
INSERT INTO `davidosullivan` (`id`, `prod_image_1`, `prod_image_2`, `prod_image_3`, `prod_title`) VALUES (1, 'images/image1.gif', 'images/image2.gif', 'images/overview.jpg', 'Air'),
(2, 'images/gip1.jpg', 'images/gip2.gif', 'images/theGipper.png', 'The Gipper'),
(3, 'images/image14.gif', 'images/theClaw.jpg', 'images/theClaw2.jpg', 'The Claw');
The PHP & Form:
<?php
$conn = mysql_connect('localhost', 'username', 'password');
mysql_select_db('database_name', $conn);
showTable();
$dd_query = "SELECT id, prod_title FROM davidosullivan ORDER BY id ASC";
$dd_res = mysql_query($dd_query);
echo '
<tr>
<form action="'.$_SERVER['PHP_SELF'].'" method="post">
<td colspan="2">
<select name="prod_id">';
while($row = mysql_fetch_array($dd_res))
{
echo '
<option value="'.$row['id'].'">'.$row['prod_title'].'</option>';
}
echo '
</select>
</td>';
echo '
<td><input type="submit" name="product_image" value="prod_image_1"></td>
<td><input type="submit" name="product_image" value="prod_image_2"></td>
<td><input type="submit" name="product_image" value="prod_image_3"></td>
</form>
</tr>
</table>';
if(isset($_POST) && !empty($_POST['prod_id']))
{
$query = "UPDATE davidosullivan SET ".$_POST['product_image']."=NULL WHERE id='".$_POST['prod_id']."'";
echo '<pre>'.$query.'</pre>';
$result = mysql_query($query);
if(!$result){ echo mysql_error(); }
if(mysql_affected_rows($conn) > 0)
{
echo 'Query Successful!!';
}
else
{
echo 'Query Failed!!';
}
}
function showTable()
{
echo '
<table>
<tr>
<th>ID</th><th>Product Name</th><th>Image 1</th><th>Image 2</th><th>Image 3</th>
</tr>';
$query = "SELECT * FROM davidosullivan ORDER BY id ASC";
$result = mysql_query($query);
while($row = mysql_fetch_array($result))
{
echo '
<tr>
<td>'.$row['id'].'</td>
<td>'.$row['prod_title'].'</td>
<td>'.$row['prod_image_1'].'</td>
<td>'.$row['prod_image_2'].'</td>
<td>'.$row['prod_image_3'].'</td>
</tr>';
}
}
?>
Now, when I do the update, it updates just fine!!!