计算php中的循环while循环[重复]

Possible Duplicate:
How to calculate multiplication value inside the while loop in PHP?

while($row = mysql_fetch_array($result))
  {
 echo "<tr>";
 echo "<td class='alt'>" . $row['id'] . "</td>";
 echo "<td>" . $row['item'] . "</td>";
echo "<td>" . $row['amount'] . "</td>";
$ss=$row['amount'];
echo '<td >'.'<input type="checkbox"  name="status" value="" >'.'</td>';
echo '<td >'.'<input type="text" name="qty">'.'</td>';

echo "<td>" . $rr1 . "</td>";

echo "</tr>";


 }

hi inthis coding how can get one input value from the user the secound value am getting from database at last perform multiplication

Strictly speaking, you can't get a value from the user with your code. To get an input you need to send a form

Lets say you have a form

<form action="theNameOfTargetScript.php" method="post">
<input type="text" name="qty"/>
<input type="submit">
</form>

Once you have submited a form like this, you need to receive the post value and then multiply it with whatever it is that you need:

while($row = mysql_fetch_array($result))
  {
 echo "<tr>";
 echo "<td class='alt'>" . $row['id'] . "</td>";
 echo "<td>" . $row['item'] . "</td>";
echo "<td>" . $row['amount'] . "</td>";
$ss=$row['amount'];
$qty=$_POST['qty']; //The important bit. And for this to be meaningful, you should check if this value exists with isset($_POST['qty']);

echo "<td>" . $ss*$qty . "</td>";

echo "</tr>";


 }

Also, You're using the concatenation wrong. Since HTML in this case is just a string, you can just type them as they are without concatenation, like this:

echo '<td ><input type="checkbox"  name="status" value="" ></td>';

Also, it seems that you have done no research in PHP whatsoever, since this is the basic principle of all PHP websites.

EDIT

Since you asked.

  • Yes, You can get the $_POST value inside a while loop.
  • No, you cant get user input in a while loop.

This kind of functionality is usually used in C++ command line-like applications, but this is not the way PHP over HTTP works.