how can we access an HTML variable in the same page?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • savyatha
    New Member
    • Mar 2007
    • 9

    #1

    how can we access an HTML variable in the same page?

    this is savyatha trying to learn & do a project using HTML, PHP with DATABASE CONNECTIVITY.
    iam unable to get the desired output due to the problems iam facing.
    they are:
    if i write action then the output is getting displayed on a new page.
    i want the output of PHP to be displayed on the same page.
    also, how can we post variables to a PHP code in the same page?
    can we call an action without SUBMIT button?
  • mainul
    New Member
    • Sep 2006
    • 51

    #2
    Hi Savyatha
    send us the code you have developed so far. otherwise it would be dificult for us to give you the exact solutions.

    best regards
    Mainul

    Comment

    • savyatha
      New Member
      • Mar 2007
      • 9

      #3
      thanks u mainul sir for responding to my thread .
      i want to explain my problem clearly here:
      i need to generate a bill online to the customer entered into the shop
      first in a select box , i have to get all the categories in the shop. for ex, fruits, vegetables, furniture etc . this shd be retrieved from the database & must be displayed on the select box.
      when once a category is selected, all the items in that category must be displayed in another select box.
      next , the quantity purchased by the customer must be entered either in a text box or in a select box.
      after this, a row of table must be displayed which consists of item id, itemname, price(unit price * quantity).
      similarly an ADD option must be provided .
      if add is clicked then again we must be able to select another category or the same, item & then the quantity $ finaly the itemid, item name, price corresponding to this item must come as a second row ie., next to the first row
      like wise, after selecting & adding all the items bought by the customer row wise like a table format, we need to add all item prices to get the total amount.

      sir! hope u have now understood clearly what actually i wants. so, sir, plz reply this v soon

      Comment

      • savyatha
        New Member
        • Mar 2007
        • 9

        #4
        the code i have developed for the implementation of the above task is:
        [php]
        <form name="f1" action="catitem .php" method='post'>
        Category:<selec t name='s1' onchange="f1.su bmit();">
        <?php
        include('adodb. inc.php');
        $db=ADONewConne ction("postgres ");
        $db->connect("local host","rams","" ,"stu");
        $q="select distinct ctgry from inv";
        echo "<option>$_ POST[s1]</option>";
        $rs=$db->Execute($q);
        while(!$rs->EOF)
        {
        $c=$rs->fields['ctgry'];
        if($c!=$_POST[s1])
        echo "<option>";
        echo $c;
        echo "</option>";
        $rs->MoveNext();
        }
        ?>
        </select>
        Item:<select name='s2'>
        <?php
        include('adodb. inc.php');
        $db=ADONewConne ction("postgres ");
        $db->connect("local host","rams","" ,"stu");
        $q="select * from inv where ctgry='$_POST[s1]'";
        $rs=$db->Execute($q);
        while(!$rs->EOF)
        {
        $in=$rs->fields['itemname'];
        echo "<option>";
        echo $in;
        echo "</option>";
        $rs->MoveNext();
        }
        ?>
        </select>
        Quantity:<input type="text" name="t1">
        <table border=5 align=center>
        <TR><Th>ITEM ID</Th><TH>ITEM NAME</TH><TH>QUANTITY </TH><TH>PRICE</TH></TR>
        <?
        include('adodb. inc.php');
        $db=ADONewConne ction("postgres ");
        $db->connect("local host","rams","" ,"stu");
        $q="select * from inv where itemname='$_POS T[s2]'";
        $rs=$db->Execute($q);
        $in=$rs->fields['itemname'];
        $ii=$rs->fields['itemid'];
        $p=$rs->fields['price'];
        $a=$_POST[t1];
        $r=$_POST[t1]*$p;
        echo "<TR><TD>$i i</TD><TD>$in</TD><TD>$a</TD><TD>$r</TD></TR></table>";
        ?>
        <input type="submit" value="add more">
        </form>
        </pre>
        </body>
        </html>[/php]
        Last edited by ronverdonk; Mar 6 '07, 05:45 PM. Reason: enclosing code within tags and warning

        Comment

        • savanm
          New Member
          • Oct 2006
          • 85

          #5
          Hi savyatha..

          i think this may satisfy ur need...

          <form name="nameofthe form" method="post" action="<? echo $_SERVER['PHP_SELF']; ?>">

          <? echo $_SERVER['PHP_SELF'];?>>

          in the above action type we get the output with in the same file..

          So try this one

          Comment

          • ronverdonk
            Recognized Expert Specialist
            • Jul 2006
            • 4259

            #6
            savyata: read the Posting Guidelines before you post any more in this forum!
            Especially the part about enclosing shown code with code or php tags!

            moderator

            Comment

            Working...