Jump to content

[SOLVED] passing the values


black_box

Recommended Posts

The file name is visit.php

 

I have a search option and

1) user will give a value

2) the page will search and give the output.

 

Now i want to pass the values to another <?PHP ?> code which is inside the the same file in visit.php

 

ok here is the example

 

code like this way:

<?PHP 

echo $pro_id;

?>
//some HTML codes
<?PHP 
$por_name_id = $pro_id; //this is the same pro_id i got from above PHP code

?> 

 

Now how to do this?? any idea ..sorry i m new in this PHP

Link to comment
Share on other sites

But the problem is i have two textfield

 

One use for search

 

another use for get input from user

 

So first user will use first textfield to search and it will show the information

 

The next textfield will let user insert a value and it will take those values from previous output and do calculation with new value and then store in database.

 

<?PHP
if (isset($_POST['search'])) //after give input and click submit
{
   $pro_id = $_POST['ID'];

}
?>
//Some html code

<?PHP
if(isset($_POST ['AddN'])) //after give input and click submit2
{
    $New_id=$pro_id+3; //How to get the value of $pro_id from the above php code
}
?>

 

 

Any idea?

Link to comment
Share on other sites

Yah i know this two things thts why i asked sorry

 

The user will search then it shows the output

and then the user give something on the another textfield

and it will take wht it get from previous output

and do calculation and show new output.

 

So actually needs to send the values from previous output

 

I think i need to use Hidden field wht u people say ??

Link to comment
Share on other sites

Now i m totally lost

 

Here is the code

 

<form name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
                  <input name="bar" type="text" id="bar">
			  
                  <td width="66" valign="bottom">
                  <input name="re" type="submit" id="re" value="Submit">
                </form>
            </table>
              <table width="295" border="0">
                <tr>
                  <td align="right"><?php
			  

	include "connect_db.php";
	 global $pro_id;
		$pro_id = $_POST['bar'];
	if(isset($_POST['bar'])) //search option for bar code 
	{		
		global $pro_id;
		$pro_id = $_POST['bar'];
		$SQL = "SELECT * FROM pro_info where pro_id = $pro_id";
        	$res= mysql_query($SQL) or die("could not register");
		if(mysql_num_rows($res)==0)

        		echo "<span class='style25'>*** No Data OR Wrong Bar Code Entered ***</span>";

    	   		$row = mysql_fetch_array($res);
			//need these variable below  
		$pro_name=$row['pro_name'];
        		
        		$pro_hand = $row['pro_in_hand' ];

         		$pro_sprice=$row['pro_s_price'];


       			
        echo" <table width='634' border='0'>
          
          <tr>
            <td width='114'> </td>
            <td width='285'><table width='274' border='1'>
              <tr>
                <td><span class='style4'>Product Name: </span></td>

                <td><span class='style4'><input name='pro_name' type='text' value='$pro_name' /></span></td>
              </tr>
              <tr>
                <td><span class='style4'>Quantity In Hand: </span></td>
                <td><span class='style4'>$pro_hand</span></td>
              </tr>
              <tr>
                <td><span class='style4'>Price Per Pc's (RM): </span></td>
                <td><span class='style5'>$pro_sprice</span></td>
              </tr>
              
             <input name='pro_H' type='hidden' id='pro_id' value='$pro_name' />
            </table>
            </td>
            <td width='99'> </td>
          </tr>
	  <tr>
            <td> </td>
            <td> </td>
            <td> </td>
            <td width='118'> </td>
          </tr>
         
        </table>  ";
	}

  echo"</td>
                </tr>
              </table>
              <table width='632' height='99' border='0'>
              <tr>
                <td width='165'> </td>
                <td width='83'><label><span class='style4'>Order Pc's : </span></label></td>
                <td width='144'><label>
			<form name='form1' method='post' action='sales.php'>
                  <input input name='order' type='text' id='order'>

                </label></td>
                <td width='222'> </td>
              </tr>
              <tr>
                <td height='21'> </td>
                <td> </td>
                <td><label></label></td>
                <td> </td>
              </tr>
              <tr>
                <td> </td>
                <td><input type='submit' name='Submit' value='Submit'></td>
                <td><input type='reset' name='Submit2' value='Reset'></td>
			 </form>
                <td> </td>
              </tr>
            </table>";
		echo" ";


		$tot_price = $pro_order*$pro_price;
		$pro_id1 =$pro_id;
		echo $pro_name;
		$pro_order;
		$pro_sprice;

		echo $tot_price;

		if(isset($_POST['order']))//after the display of the info from the above bar code search the user will give a order number and submit then it will store into the database with all the field from first options to till now
	{

		//need all the variable from the first search options here...

		$SQL = "INSERT into pro_order  VALUES ('$pro_id','$pro_name','$pro_order','$pro_sprice','$tot_price')";
      		mysql_query($SQL) or die("could not register");
	echo" <table width='688' border='0'>
  					<tr>
   					 <td width='35'> </td>
   					 <td width='643'><table width='643' border='1'>
    				  <tr>
        					<td width='87' align='center'><span class='style4'>Product ID: </span></td>
        					<td width='283' align='center'>Product Name </td>
        					<td width='85' align='center'>Price /Pc's </td>
        					<td width='66' align='center'>Order Pc's </td>
        					<td width='88' align='center'>Total Price </td>
      				</tr>
      				<tr>
        			[b][color=purple]<td>$pro_id</td>
        			<td>$pro_name</td>
        			<td>$pro_sprice</td>
        			<td>$pro_order</td>
        			<td>$tot_price</td>[/color][/b]
      			</tr>
    		</table></td>
  					</tr>
		</table>  ";
		}
		?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.