View Full Version : Problem with value can pass to this page but cannot display & store!

08-27-2006, 05:23 PM
The print_r( $_POST ); shows that the value from add_hole.php form can pass value to this add_hole_ac.php.

Array ( [customer_id] => 6 [num_of_hole] => 2 [hole_num0] => 1 [types_of_drilling0] => 0 [size0] => 1 [hr_from0] => 1 [hr_to0] => 1 [bit0] => 1 [core_rec0] => 1 [hours0] => 1 [hole_num1] => 2 [types_of_drilling1] => 0 [size1] => 2 [hr_from1] => 2 [hr_to1] => 2 [bit1] => 2 [core_rec1] => 2 [hours1] => 2 [Submit] => Submit )

But it is funny that $_POST cannot show the value and insert query cannot stored into database as well. Please guide!

include '../../config.php';
include '../../opendb.php';
$customer_id= $_POST["customer_id"];
$num_of_hole= $_POST["num_of_hole"];
print_r( $_POST );

$sql3 = "SELECT * FROM customer WHERE customer_id='$customer_id'";
$result3 = mysql_query($sql3);

//list($plod_id)=mysql_fetch_row(mysql_query("SELECT plod_id FROM plod"));

for($i=0;$i<$num_of_hole;$i++){//start of for loop



$sql="INSERT INTO hole(plod_id, hole_num, types_of_drilling, size, hr_from, hr_to, meters_drilled, bit, core_rec, hours)VALUES('$plod_id', '$hole_num','$types_of_drilling', '$size', '$hr_from', '$hr_to', '$meter_drilled', '$bit', '$core_rec', '$hours')";
$result=mysql_query($sql)or die(mysql_error());
}//end of for loop
<table width="100%" border="0" align="center" cellspacing="0">
<!--add hidden value-->
<input name="customer_id" type="hidden" value="<? echo $customer_id; ?>">
<input name="num_of_hole" type="hidden" value="<? echo $num_of_hole; ?>">
<!--end of add hidden value -->
<tr bgcolor="#999999">
<td width="113"><div align="center" class="style1">Hole Number </div></td>
<td width="184"><div align="center" class="style1">Types of Drilling </div></td>
<td width="94"><div align="center" class="style1">Size</div></td>
<td width="129"><div align="center" class="style1">From <br>
<td width="104"><div align="center" class="style1">To<br>
<td width="145"><div align="center" class="style1">Metres Drilled </div></td>
<td width="172"><div align="center" class="style1">Bit#</div></td>
<td width="113"><div align="center"><span class="style1">Core Rec. </span></div></td>
<td colspan="3"><div align="center" class="style1">Hours</div></td>
<?php if($result){
$sql4="SELECT SUM($meter_drilled) as count FROM plod";
<td><div align="center"><?php echo $_POST['hole_num'];?></div></td>
<td><div align="center"><?php echo $_POST['types_of_drilling'];?></div></td>
<td><div align="center"><?php echo $_POST['size'];?></div></td>
<td><div align="center"><?php echo $_POST['hr_from'];?></div></td>
<td><div align="center"><?php echo $_POST['hr_to'];?></div></td>
<td><div align="center"><?php echo $meter_drilled;?></div></td>
<td><div align="center"><?php echo $_POST['bit'];?></div></td>
<td><div align="center"><?php echo $_POST['core_rec'];?></div></td>
<td colspan="3"><div align="center"><?php echo $_POST['hours'];?></div></td>
<?php }?>
<td colspan="11">*</td>
<td colspan="4"><strong>Total Meters: </strong></td>
<td width="129"><?php echo $rows4['count']?></td>
<td colspan="11">*</td>
<td colspan="11"><div align="center">
<input name="Button" type="button" onClick="MM_goToURL('parent','equipment.php');return document.MM_returnValue" value="Save & Proceed">
<?php }?>

08-27-2006, 10:56 PM
Before looking in depth, I saw this construction

for the 1st go (when $i=0) this generates:


Now I am sure you meant to assign (for the 1st time anyway)


So you first have to change those array assignments, like this:


You better get these assignments right before anything else.

Ronald :cool: