ขอการแนะนำครับ Fatal error: Unsupported operand types in C:\
Fatal error: Unsupported operand types in C:\AppServ\www\proapartment\admin\calculated2.php on line 8
calculated.php
<?
while ($dbarr_cat = mysql_fetch_array($result_cat)) {
$sql_m="SELECT * FROM tb_detail WHERE room_id='$dbarr_cat[room_id]' order by tb_detail.detail_id DESC";
$result_m = mysql_query($sql_m);
$dbarr_m=mysql_fetch_array($result_m);
//$total_m=mysql_num_rows($result_m);
?>
<tr>
<!-- <td height="20" valign="top" align="center" class="style3"><?=$a;?></td>-->
<td width="5%" height="20" align="center" class="style3"><?=$dbarr_cat['room_name'];?></td>
<td height="20" align="center" class="style3"><?=$dbarr_cat['name'];?>
<input type="hidden" id="book_id" name="book_id[]" value="<?=$dbarr_cat['book_id'];?>"size="2" />
<input type="hidden" id="room_id" name="room_id[]" value="<?=$dbarr_cat['room_id'];?>"size="2" />
</td>
<!-- <td height="20" align="center" class="style3"><?=$dbarr_m['unit_w'];?><font color="#FF0000"><? if ($dbarr_m['unit_w']=="") { echo "=NEW="; }?></font></td> -->
<td align="center"><input type="text" id="old_w" name="old_w[]"value="<?=$dbarr_m['unit_w'];?>" size="2" disabled /> </td>
<td align="center"><input type="text" id="unit_w" name="unit_w[]" size="5"/>
</td>
<!-- <td height="20" align="center" class="style3"><?=$dbarr_m['unit_c'];?><font color="#FF0000"><? if ($dbarr_m['unit_c']=="") { echo "=NEW="; }?></font></td>-->
<td align="center"><input type="text" id="old_c" name="old_c[]"value="<?=$dbarr_m['unit_c'];?>" size="2" disabled /> </td>
<td align="center"><input type="text" id="unit_c" name="unit_c[]" size="5"/>
</td>
</tr>
<?
}
?>
calculated2.php
<?
session_start();
$book_id = $_POST['book_id'];
$room_id = $_POST['room_id'];
$unit_c = $_POST['unit_c'];
$unit_w = $_POST['unit_w'];
$old_c = $_POST['old_c'];
$old_w = $_POST['old_w'];
<span style="background-color: rgb(255, 0, 0);">$del_w = $_POST['unit_w']-$_POST['unit_w'];</span>
<span style="background-color: rgb(255, 0, 0);">$del_c = $_POST['unit_c']-$_POST['old_c'];</span>
$years=date("Y") + 543;
$months=date("m");
$days=date("d");
$datenow=$days . "/" . $months . "/" . $years;
//$price_water=$unit_w*30;
//$price_charge=$unit_c*7;
include ('../system/connect.php');
include ('../system/function.php');
for ($i=0; $i<count($book_id); $i++)
{
$sql="insert into tb_detail(book_id, room_id, unit_w, unit_c, price_water, price_charge, date_bill , bill_status)
values('".$book_id[$i]."','".$room_id[$i]."','".$del_w[$i]."','".$del_c[$i]."','".$price_water."','".$price_charge."','".$datenow."','1')";
$result=mysql_db_query($dbname,$sql);
}
รบการช่วยแนะนำหน่อยครับคือว่าผมเริ่มหัดเขียนครับ
calculated.php
<?
while ($dbarr_cat = mysql_fetch_array($result_cat)) {
$sql_m="SELECT * FROM tb_detail WHERE room_id='$dbarr_cat[room_id]' order by tb_detail.detail_id DESC";
$result_m = mysql_query($sql_m);
$dbarr_m=mysql_fetch_array($result_m);
//$total_m=mysql_num_rows($result_m);
?>
<tr>
<!-- <td height="20" valign="top" align="center" class="style3"><?=$a;?></td>-->
<td width="5%" height="20" align="center" class="style3"><?=$dbarr_cat['room_name'];?></td>
<td height="20" align="center" class="style3"><?=$dbarr_cat['name'];?>
<input type="hidden" id="book_id" name="book_id[]" value="<?=$dbarr_cat['book_id'];?>"size="2" />
<input type="hidden" id="room_id" name="room_id[]" value="<?=$dbarr_cat['room_id'];?>"size="2" />
</td>
<!-- <td height="20" align="center" class="style3"><?=$dbarr_m['unit_w'];?><font color="#FF0000"><? if ($dbarr_m['unit_w']=="") { echo "=NEW="; }?></font></td> -->
<td align="center"><input type="text" id="old_w" name="old_w[]"value="<?=$dbarr_m['unit_w'];?>" size="2" disabled /> </td>
<td align="center"><input type="text" id="unit_w" name="unit_w[]" size="5"/>
</td>
<!-- <td height="20" align="center" class="style3"><?=$dbarr_m['unit_c'];?><font color="#FF0000"><? if ($dbarr_m['unit_c']=="") { echo "=NEW="; }?></font></td>-->
<td align="center"><input type="text" id="old_c" name="old_c[]"value="<?=$dbarr_m['unit_c'];?>" size="2" disabled /> </td>
<td align="center"><input type="text" id="unit_c" name="unit_c[]" size="5"/>
</td>
</tr>
<?
}
?>
calculated2.php
<?
session_start();
$book_id = $_POST['book_id'];
$room_id = $_POST['room_id'];
$unit_c = $_POST['unit_c'];
$unit_w = $_POST['unit_w'];
$old_c = $_POST['old_c'];
$old_w = $_POST['old_w'];
<span style="background-color: rgb(255, 0, 0);">$del_w = $_POST['unit_w']-$_POST['unit_w'];</span>
<span style="background-color: rgb(255, 0, 0);">$del_c = $_POST['unit_c']-$_POST['old_c'];</span>
$years=date("Y") + 543;
$months=date("m");
$days=date("d");
$datenow=$days . "/" . $months . "/" . $years;
//$price_water=$unit_w*30;
//$price_charge=$unit_c*7;
include ('../system/connect.php');
include ('../system/function.php');
for ($i=0; $i<count($book_id); $i++)
{
$sql="insert into tb_detail(book_id, room_id, unit_w, unit_c, price_water, price_charge, date_bill , bill_status)
values('".$book_id[$i]."','".$room_id[$i]."','".$del_w[$i]."','".$del_c[$i]."','".$price_water."','".$price_charge."','".$datenow."','1')";
$result=mysql_db_query($dbname,$sql);
}
รบการช่วยแนะนำหน่อยครับคือว่าผมเริ่มหัดเขียนครับ
$_POST['unit_w'] เป็น array ครับ เข้าใจว่าไม่สามารถลบกันได้ครับต้องระบบว่าจะลบ element ที่เท่าไหร่ เช่น $_POST['unit_w'][0]
ผิดถูก ยังไง รบกวนผู้รู้ตอบหน่อยครับ
แล้วอย่างนี้พอมีวิธีไหนไหมครับที่จะนำค่ามาคำนวณได้ครับ...ขอคำแนะนำหน่อยครับ
555+++
ถามคำถาม ไม่รู้ว่าจะตอบยังไงเลย...
ไม่รู้ว่าจะทำอะไร และทำไมจึงต้องเอามาลบกัน ลองดู input array ดูครับ