$xtem=$item*$utem. Получается, что $item=4, $utem=2, $xtem=8.
дело в том, что эта восьмерка записывается во все строки 3-го столбца. Что я не так сделал?
<?php
require_once("scripts/dbdata.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN">
<html xmlns="http://www.w3.org/1999/xhtml" lang="ru">
<head>
<title>WebListEditor</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="css/styles.css" />
<script type="text/javascript" src="scripts/libs/prototype.js"></script>
<script type="text/javascript" src="scripts/libs/scriptaculous.js?load=effects,controls"></script>
<script type="text/javascript" src="scripts/tasks.js"></script>
</head>
<body>
<?php $con = connect(); ?>
<div id="content">
<?php
$res = mysql_query("SELECT * FROM listitems");
if ($res === FALSE) {
echo "Ошибка при отправке запроса к БД:".mysql_error();
}
elseif (mysql_num_rows($res) == 0) {
echo "<div id=\"noItems\">Записей нет</div>";
}
else {
?>
<p><b>Таблица показателей</b></p>
<ul id="list">
<?php
$i = 0;
while ($item = mysql_fetch_array($res, MYSQL_ASSOC)) {
$i++;
?>
<li id="listNum_<?php echo $i - 1; ?>">
<table width="70" border="1">
<tr>
<td width="70">
<div class='itemNum'><?php echo $i; ?></div>
</td>
<td width="120">
<div class='itemValue' onclick='closeOtherEditors(<?php echo $i - 1; ?>)'
id="itemId_<?php echo $item['id']; ?>"><?php echo $item['item']; ?></div>
<td>
<td>
<div class='utemValue' onclick='closeOtherEditors(<?php echo $i-1 ; ?>)'
id="utemId_<?php echo $item['id']; ?>"><?php echo $item['utem']; ?></div>
</td>
<?
//Фоhмируем запрос на вычисление xtem
include ("bd.php");
$query2="select * from listitems order by 1";
$result2=mysql_query($query2);
$total_rows=mysql_num_rows($result2);
//$row2=mysql_fetch_row($result2);
$row2=mysql_fetch_row($result2);
$total_cols=count($row2);
print "<form name='form3' method='post' action='index.php'>";
if ($row2[2] && $row2[1]&&$row2[0])
{
$xtem=round(($row2[2] * $row2[1]),1);
}
$query3="insert into listitems values ('".$row2[0]."','".$row2[1]."','".$row[2]."','".$xtem."')";
$result3=mysql_query($query3);
?>
<?
print "<td>".$xtem."</td>";
?>
<td>
<a href="#" class="deleteLink" onclick="deleteItem(<?php echo $item['id']; ?>)">
<img src="css/images/delete.gif" alt="Удалить" title="Удалить" />
</td>
</tr>
</table>
</a>
<script type="text/javascript">
editors.push(addEditor("itemId_<?php echo $item['id'];?>","<?php echo $item['id'];?>"));
editors.push(addEditor2("utemId_<?php echo $item['id'];?>","<?php echo $item['id'];?>"));
editors.push(addEditor3("xtemId_<?php echo $item['id'];?>","<?php echo $item['id'];?>"));
</script>
</li>
<?php
}
?>
</ul>
<?php
}
?>
</div>
<?php
mysql_free_result($res);
mysql_close($con);
?>
<form action="#" id="add_item_form">
<p>
<label for="item_value"></label>
<input type="text" id="item_value" size="20" />
<input type="text" id="utem_value" size="20" />
<input type="button" value="Добавить" onclick="addItem()" />
</p>
</form>
</body>
</html>