0

当我输入长度和宽度选择的项目时,平方英尺是正确的,但在定价时,它总是将总平方英尺乘以第一个项目的价格......价格在一段时间内,但它与产品不同步。 ..我应该在哪里寻找任何想法?

while($info = mysql_fetch_array( $data )) 
 { 
$resim = $info[resim];
$isim = $info[isim];
$boyut = $info[boyut];
$pcs = $info[adet];
$sqft = $info[sqft];
$TileNameList .= "<option value=\"$sqft\">$isim $boyut</option>";
$price .= $info[price];
}
/////////Formdan gelen yada Giden//////////////
$length =htmlspecialchars(stripslashes($_POST['Length'])); 
$width =htmlspecialchars(stripslashes($_POST['Width'])); 
$TileSqft =htmlspecialchars(stripslashes($_POST['TileName'])); 

/////Matematiksel islemler/////////

$equals = $length * $width;
$box = round($equals / $TileSqft);
$TotalSqft = $box * $TileSqft;
$TotalPrice = $TotalSqft * $price;

这就是我获得长度*宽度但总价格错误的表格。

  <td><form id="form5" name="form5" method="post" action="">
        <select name="TileName" id="TileName">
        <option>Select</option>
<?php  echo ($TileNameList); ?>
        </select>
      </td>
      <td><input name="Length" type="text" id="Length"/></td>
      <td><input type="text" name="Width" id="Width"/></td>
      <td><input type="text" name="Sqft" id="Sqft" value="<?php echo ($equals); ?>"/></td>
      <td><?php echo "You will need <span style=\"color:red\">$box</span> Boxes<br> Which is <span style=\"color:red\">$TotalSqft</span> "; ?></td>
      <td><?php echo "$$TotalPrice"; ?></td>
    </tr>
    <tr >
      <td colspan="6" align="center">
        <input type="submit" name="Submit" id="Submit" value="Submit" />
      </form></td>
4

1 回答 1

0

您正在附加$price我认为您应该添加的price 代码是

$price=0;//Add this line
while($info = mysql_fetch_array( $data )) 
{ 
$resim = $info[resim];
$isim = $info[isim];
$boyut = $info[boyut];
$pcs = $info[adet];
$sqft = $info[sqft];
$TileNameList .= "<option value=\"$sqft\">$isim $boyut</option>";
$price += $info[price];//change this line
}
/////////Formdan gelen yada Giden//////////////
$length =htmlspecialchars(stripslashes($_POST['Length'])); 
$width =htmlspecialchars(stripslashes($_POST['Width'])); 
$TileSqft =htmlspecialchars(stripslashes($_POST['TileName'])); 

/////Matematiksel islemler/////////

$equals = $length * $width;
$box = round($equals / $TileSqft);
$TotalSqft = $box * $TileSqft;
$TotalPrice = $TotalSqft * $price;
于 2013-02-08T04:31:56.017 回答