當我進入lenght和寬度所選項目平方英尺是正確的,但是當涉及到定價,它總是乘以總平方英尺與第一項目價格......價格之內雖然它不在產品中......我應該在這方面尋找什麼想法?如何同步與MySQL表中選擇列表的值中,
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;
,這其中i得到長*寬,但總價格的形式出來的錯誤..
<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>
[**請不要在新代碼'mysql_ *'功能**](http://bit.ly/phpmsql)。他們不再被維護[並且被正式棄用](http://j.mp/XqV7Lp)。看到[**紅框**](http://j.mp/Te9zIL)?學習[*準備的語句*](http://j.mp/T9hLWi),並使用[PDO](http://php.net/pdo)或[MySQLi](http://php.net/ mysqli) - [這篇文章](http://j.mp/QEx8IB)將幫助你決定哪個。 – Kermit
這是什麼$價格。= $信息[價格];你爲什麼要使用這個連接? –
嘗試更改'$ price。= $ info [price];'到'$ price + = $ info ['price'];'並確保初始化變量BEFORE。 '$價格= 0;' –