0

選択したアイテムの長さと幅を入力すると、sqftは正しいですが、価格設定に関しては、常に合計sqftに最初のアイテムの価格を掛けます...価格はしばらくの間ですが、製品とは異なります。 ..私がこれで見るべきアイデアはありますか?

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 に答える