ok, i got this to work for me on a test db. since i don't know you're data/table structure, it may break. but maybe it will help. try testing the whole code as is. it can definitely be optimized.
i wasn't exactly sure what you're trying to do. using 1 Update statement to change multiple rows would set all the fields in those rows to the same data. is that what you want? i assumed not, so i put it in a for loop.
the other main thing i did was make the input textboxs multidimensional arrays with the update_id and field# as keys....like this....
<td><input type=checkbox name=update_id[] value='1'></td>
<td>1</td>
<td><input type=text name=update_field[1][1] size=20 value=New></td>
<td><input type=text name=update_field[1][2] size=20 value=New1></td>
<td><input type=text name=update_field[1][3] size=20 value=New2></td>
<td><input type=text name=update_field[1][4] size=20 value=New3></td>
</tr>
<tr>
<td><input type=checkbox name=update_id[] value='2'></td>
<td>2</td>
<td><input type=text name=update_field[2][1] size=20 value=Joe></td>
<td><input type=text name=update_field[2][2] size=20 value=200 Sale></td>
<td><input type=text name=update_field[2][3] size=20 value=Temple></td>
<td><input type=text name=update_field[2][4] size=20 value=Brazil></td>
</tr>
<tr>
<td><input type=checkbox name=update_id[] value='3'></td>
<td>3</td>
<td><input type=text name=update_field[3][1] size=20 value=John></td>
<td><input type=text name=update_field[3][2] size=20 value=444 Kiss></td>
<td><input type=text name=update_field[3][3] size=20 value=Houston></td>
<td><input type=text name=update_field[3][4] size=20 value=United K></td>
</tr>
<html>
<head>
<title>Update rows in database table</title>
</head>
<body>
<?
$host = "myhost"; //database host
$user = "myusername"; //database user
$password = "mypw"; //database password
$database = "mydb"; //name of database
$table = "catalog"; //name of table
$columns = "catalog,Name,StreetAddress,City,Country";
$unique_column = "catalog";
$link_id = mysql_connect($host,$user,$password) or die("Cannot connect to database");
$db = mysql_select_db($database) or die("Cannot select database");
$i = explode(",",$columns);
$num_columns = count($i);
if(isset($HTTP_POST_VARS[update]))
{
if(($num_ids=count($update_id)) > 0)
{
$update_rows = implode(",",$update_id);
for($j=0;$j<=$num_ids-1;$j++){
$id_value=$update_id[$j];
$query = "UPDATE $table SET Name='".$update_field[$id_value][j+1]."' , StreetAddress='".$update_field[$id_value][j+2]."', City='".$update_field[$id_value][j+3]."', Country='".$update_field[$id_value][j+4]."' WHERE $unique_column=$id_value";
//echo $query.'<br>';
$result = mysql_query($query) or die("Error in Query: >>>$query<<<. Error: " . mysql_error());
}
$affected = mysql_affected_rows();
$count = count($update_id);
$msg = "$affected / $count rows updated";
}
else
{
$msg = "No rows selected for updating";
}
}
echo "<form method='post' action='$PHP_SELF'>\n";
echo "<table border='1' cellpadding='1' cellspacing='1'>\n";
if(isset($msg))
{
echo "<tr><td align='center' colspan='" . ($num_columns+1) . "'><i>$msg</i></td></tr>\n";
}
echo "<tr>\n";
echo "<td align='center'><b>Update?</b></td>\n";
for($x=0;$x<$num_columns;$x++)
{
echo "<td align='center'><b>" . $i[$x] . "</b></td>\n";
}
echo "</tr>\n";
$query = "SELECT $columns FROM $table";
$result = mysql_query($query) or die("Error in Query >>>$query<<<. Error: " . mysql_error());
if($row = mysql_fetch_array($result))
{
do{
echo "<tr>\n";
echo "<td><input type=checkbox name=update_id[] value='" . $row[$unique_column] . "'></td>\n";
echo "<td>$row[$unique_column]</td>\n";
for($x=1;$x<$num_columns;$x++)
{
echo "<td><input type=text name=update_field[$row[$unique_column]][$x] size=20 value=$row[$x]></td>\n";
}
echo "</tr>\n";
}while($row = mysql_fetch_array($result));
echo "<tr><td align='center' colspan='" . ($num_columns + 1) . "'><input type='submit' name='update' value='Update Selected Products'></td></tr>\n";
}
echo "</table>\n";
echo "</form>\n";
?>
</body>
</html>