You do need to post a better explanation and example, and provide the relavent database schema, as bastien mentioned.
Using some guesswork, from what I see, this would be your code in simplified form:
//assume $cur has been initialised
mysql_query("BEGIN");
$num_iters = $cols * $rows;
for ($i = 0; $i < $num_iters; ++$i) {
$cc = $_POST['d' . $i];
$k = ($i % 30) + 1;
mysql_query("UPDATE `bc_segments` SET `$k`='$cc' WHERE `IDST`=$cur");
if ($k == 30) {
++$cur;
}
}
mysql_query("COMMIT");
What you can try is to update entire rows at once. There will be 30 columns per row, so you can try:
//assume $cur has been initialised
$i = 0;
$i_max = $cols * $rows;
while ($i < $i_max) {
$pairs = array();
$j = $i;
$i += 30;
while ($j < $i);
$cc = $_POST['d' . $j];
++$j;
$pairs[] = "`$j`='$cc'";
}
mysql_query("UPDATE `bc_segments` SET " . implode(',', $pairs) . " WHERE `IDST`=$cur");
++$cur;
}
This should reduce the number of queries by a factor of 30, assuming it works. If you can use them, transactions would still be a good choice.
How does it not work? Still too slow, or fails? The use of transactions may not be available.