passing values to php print page

Posted by DAFFODIL on Stack Overflow See other posts from Stack Overflow or by DAFFODIL
Published on 2010-06-01T14:49:21Z Indexed on 2010/06/01 14:53 UTC
Read the original article Hit count: 305

Filed under:

In this wen i select a value in drop down box it will list out that name value in table .There will be a check box ,the checked values should be passed to pring page which is below the 1st part of code.

Any help ii be appreciated

<?php 
$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("form1", $con);


error_reporting(E_ALL ^ E_NOTICE);
$nam=$_REQUEST['select1'];


 $row=mysql_query("select * from inv where name='$nam'");
while($row1=mysql_fetch_array($row))
{ 
$Name=$row1['Name'];
 $Address =$row1['Address'];
 $City=$row1['City'];
        $Pincode=$row1['Pincode'];
 $No=$row1['No'];
 $Date=$row1['Date'];
 $DCNo=$row1['DCNo'];
 $DcDate=$row1['DcDate'];
 $YourOrderNo=$row1['YourOrderNo'];
 $OrderDate=$row1['OrderDate'];
 $VendorCode=$row1['VendorCode'];
 $SNo=$row1['SNo'];
 $descofgoods=$row1['descofgoods'];
 $Qty=$row1['Qty'];
 $Rate=$row1['Rate'];
 $Amount=$row1['Amount'];
}

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
 <script type="text/javascript">
    function ram()
    {

    var q=document.getElementById('qty').value;

    var r=document.getElementById('rate').value;

    document.getElementById('amt').value=q*r;

    }

    </script>
</head>

<body>
<form id="form1" name="form1" method="post" action="">
  <table width="1315" border="0">
  <script type="text/javascript">
function g()
{
form1.submit();
}
</script>
  <tr>
    <th>Name</th>
    <th align="left"><select name="select1" onchange="g();">
      <option value="" selected="selected">select</option>
      <?php $row=mysql_query("select Name from inv ");
while($row1=mysql_fetch_array($row))
{ ?>
      <option value="<?php echo  $row1['Name'];?>"><?php echo  $row1['Name'];?></option>
      <?php } ?>
    </select></th>
  </tr>
  <tr>
    <th>Address</th>
    <th align="left"><textarea name="Address"><?php echo $Address;?></textarea></th>
  </tr>
  <tr>
    <th>City</th>
    <th align="left"><input type="text" name="City" value='<?php echo $City;?>' /></th>
  </tr>
  <tr>
    <th>Pincode</th>
    <th align="left"><input type="text" name="Pincode"  value='<?php echo $Pincode;?>'></th>
  </tr>
  <tr>
    <th>No</th>
    <th align="left"><input type="text" name="No2" value='<?php echo $No;?>' readonly="" /></th>
  </tr>
  <tr>
    <th>Date</th>
    <th align="left"><input type="text" name="Date" value='<?php echo $Date;?>' readonly="" /></th>
  </tr>
  <tr>
    <th>DCNo</th>
    <th align="left"><input type="text" name="DCNo" value='<?php echo $DCNo;?>' readonly="" /></th>
  </tr>
  <tr>
    <th>DcDate:</th>
    <th align="left"><input type="text" name="DcDate" value='<?php echo $DcDate;?>' /></th>
  </tr>
  <tr>
    <th>YourOrderNo</th>
    <th align="left"><input type="text" name="YourOrderNo" value='<?php echo $YourOrderNo;?>' readonly="" /></th>
  </tr>
  <tr>
    <th>OrderDate</th>
    <th align="left"><input type="text" name="OrderDate" value='<?php echo $OrderDate;?>' readonly="" /></th>
  </tr>
  <tr>
<th width="80">VendorCode</th>
  <th width="1225" align="left"><input type="text" name="VendorCode"  value='<?php echo $VendorCode;?>' readonly="" /></th>
</tr>
  </table>
  <table width="1313" border="0">

    <tr>
      <td width="44">&nbsp;</td>
      <td width="71">SNO</td>
      <td width="527">DESCRIPTION</td>
      <td width="214">QUANTITY</td>
      <td width="214">RATE/UNIT</td>
      <td width="217">AMOUNT</td>
    </tr>
    <?php $i=1;  
  $row=mysql_query("select * from inv where Name='$nam'");
while($row1=mysql_fetch_array($row))
{ 
$descofgoods=$row1['descofgoods'];
 $Qty=$row1['Qty'];
 $Rate=$row1['Rate'];
 $Amount=$row1['Amount'];
?>
    <tr>
      <td><input type="checkbox" name="checkbox" value="checkbox" /></td>
      <td><input type="text" name="No" value='<?php echo $No;?>' readonly=""/></td>
      <td><input type="text" name="descofgoods" value='<?php echo $descofgoods;?>' /></td>
      <td><input type="text" name="qty" maxlength="50000000" id="qty"/></td>
      <td><input type="text" name="Rate"  value='<?php echo $Rate;?>' id="rate" onclick="ram()";></td>
      <td><input type="text" name="Amount"   id="amt"/></td>
    </tr>
  <?php  $i++;} ?>
    <tr>
      <th colspan="2"><a href="pp.php?msg=<?php echo $nam;?>">Print</a></th>
    </tr>
  </table>
  <label></label>
</form>
</body>
</html>

-

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title></title>
<script type = "text/javascript">
function a()
{
    var q = document.getElementsByName('Amount');
    var count = 0;
    for (i = 0; i < q.length; i++)
        count += parseInt(q[i].value,10);
    document.getElementById('s').value = count;
}
</script>
</head>
<?php 
$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("form1", $con);


error_reporting(E_ALL ^ E_NOTICE);
$nam=$_GET['msg'];

 $row=mysql_query("select * from inv where Name='$nam'");
while($row1=mysql_fetch_array($row))
{ 
$Name=$row1['Name'];
 $Address =$row1['Address'];
 $City=$row1['City'];
    $Pincode=$row1['Pincode'];
 $No=$row1['No'];
 $Date=$row1['Date'];
 $DCNo=$row1['DCNo'];
 $DcDate=$row1['DcDate'];
 $YourOrderNo=$row1['YourOrderNo'];
 $OrderDate=$row1['OrderDate'];
 $VendorCode=$row1['VendorCode'];
 $SNo=$row1['SNo'];
 $descofgoods=$row1['descofgoods'];
 $Qty=$row1['Qty'];
 $Rate=$row1['Rate'];
 $Amount=$row1['Amount'];
}

?>
<body>
<form id="form1" name="form1" method="post" action="">
  <table width="846" border="0">
    <tr>
      <td width="411" height="113">&nbsp;</td>
      <td width="412">&nbsp;</td>
    </tr>
  </table>
  <table width="846" border="0">
    <tr>
      <td height="38">&nbsp;</td>
    </tr>
  </table>
  <table width="846" border="0">

    <tr>
      <td width="390" rowspan="4">&nbsp;</td>
      <td width="92" height="35">&nbsp;</td>
      <td width="136"><?php echo $No;?></td>
      <td width="36">&nbsp;</td>
      <td width="170"><?php echo $Date;?></td>
    </tr>
    <tr>
      <td height="37">&nbsp;</td>
      <td><?php echo $DCNo;?></td>
      <td>&nbsp;</td>
      <td><?php echo $DcDate;?></td>
    </tr>
    <tr>
      <td height="34">&nbsp;</td>
      <td><?php echo $YourOrderNo;?></td>
      <td>&nbsp;</td>
      <td><?php echo $OrderDate;?></td>
    </tr>
    <tr>
      <td height="29">&nbsp;</td>
      <td><?php echo $VendorCode;?></td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
  </table>
  <table width="845" border="0">
    <tr>
      <td height="38">&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td width="34">&nbsp;</td>
      <td width="457">&nbsp;</td>
      <td width="104">&nbsp;</td>
      <td width="79">&nbsp;</td>
      <td width="149">&nbsp;</td>
    </tr>
   <?php $i=1;  
  $row=mysql_query("select * from inv where Name='$nam'");
while($row1=mysql_fetch_array($row))
{ 
$descofgoods=$row1['descofgoods'];
 $Qty=$row1['Qty'];
 $Rate=$row1['Rate'];
 $Amount=$row1['Amount'];
?>
            <tr>
              <td><?php echo $i;?></td>
              <td><?php echo $descofgoods;?></td>
              <td><?php echo $Qty;?></td>
              <td><?php echo $Rate;?></td>
              <td><input name="Amount" type = "text" value="<?php echo $Amount; ?>"  /></td>
            </tr>   


   <?php  $i++;} ?>
  </table>
  <table width="844" border="0">

    <tr>
      <td width="495" height="1065">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
        <input type="text" name="textfield2" width="150" />        &nbsp; &nbsp; &nbsp; &nbsp; </td>
      <td width="191">&nbsp;</td>
      <td width="144"><input type="text" name="to"  id="s" onclick="a()";/></td>


    </tr>

  </table>
</form>
</body>
</html>

© Stack Overflow or respective owner

Related posts about php