Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Aug 2006
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Problem with value can pass to this page but cannot display & store!

    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!

    PHP Code:
    <?php 
    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); 
    $row3=mysql_fetch_array($result3); 

    //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 

    $hole_num=$_POST[hole_num][$i]; 
    $company_name=$row3['company_name'][$i]; 
    $types_of_drilling=$_POST[types_of_drilling][$i]; 
    $size=$_POST[size][$i]; 
    $hr_from=$_POST[hr_from][$i]; 
    $hr_to=$_POST[hr_to][$i]; 
    $bit=$_POST[bit][$i]; 
    $core_rec=$_POST[core_rec][$i]; 
    $hours=$_POST[hours][$i]; 

    $meter_drilled=$hr_to-$hr_from

    $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> 
              (Metres)</div></td> 
          <td width="104"><div align="center" class="style1">To<br> 
              (Metres)</div></td> 
          <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> 
        </tr> 
        <?php if($result){ 
        for(
    $i=0;$i<$num_of_hole;$i++){ 
        
    $sql4="SELECT SUM($meter_drilled) as count FROM plod"
        
    $result4=mysql_query($sql4); 
        
    $rows4=mysql_fetch_array($result4);?> 
        <tr> 
          <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> 
        </tr> 
        <?php }?> 
        <tr> 
          <td colspan="11">*</td> 
        </tr> 
        <tr> 
          <td>*</td> 
          <td>*</td> 
          <td>*</td> 
          <td>*</td> 
          <td>*</td> 
          <td>*</td> 
          <td colspan="4"><strong>Total Meters: </strong></td> 
          <td width="129"><?php echo $rows4['count']?></td> 
        </tr> 
        <tr> 
          <td colspan="11">*</td> 
        </tr> 
        <tr> 
          <td colspan="11"><div align="center"> 
            <input name="Button" type="button" onClick="MM_goToURL('parent','equipment.php');return document.MM_returnValue" value="Save & Proceed">       
          </div></td> 
        </tr> 
        <?php }?> 
      </form> 
    </table> 
    <?php 
    mysql_close
    (); 
    ?>

  • #2
    New Coder
    Join Date
    Aug 2006
    Location
    Netherlands
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Before looking in depth, I saw this construction
    PHP Code:
    $hole_num=$_POST[hole_num][$i]; 
    for the 1st go (when $i=0) this generates:
    PHP Code:
    $hole_num=$_POST[hole_num][0]; 
    Now I am sure you meant to assign (for the 1st time anyway)
    PHP Code:
    $hole_num=$_POST[hole_num0]; 
    So you first have to change those array assignments, like this:
    PHP Code:
    $hole_num=$_POST[hole_num.$i]; 
    You better get these assignments right before anything else.

    Ronald
    Last edited by ronverdonk; 08-27-2006 at 11:02 PM.
    RTFM is an almost extinct art form, it should be subsidized.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •