DONE | urgent:i desperately need your help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
gothica
Forum Newbie
Posts: 15
Joined: Thu Sep 08, 2005 5:24 am

DONE | urgent:i desperately need your help

Post by gothica »

hello there! i need assistance on this code problem of mine. this is for a school project and ive been trying to figure this out for days and i'm running out of time and options. well, here goes:

first you might want to see the interface so as you'll have clue as to what im talking about
Image

as you will see on the interface on left side of the screen there are text boxes with buttons right next to it

Code: Select all

meal : [textbox for quantity][textbox for amount] [button]
this is the part where user input is accepted, and once the user has clicked the button it will then update the text boxes on the right side of the screen based on the number of inputs by the user

Code: Select all

user input (left side)
meal : [4  ][30  ] [ME]

*once the user pushes the [ME] button...
output (right side)
meal : [4  ][ 120] = [120]
lets say the user made another entry

Code: Select all

user input (left side)
meal : [2  ][15  ] [ME]

*once the user pushes the [ME] button the program will just continue computing from the last entry...
output (right side)
meal : [6  ][ 150] = [150]
and then once the user clicks on the [process order] button he will get redirected to a page that will show a summary of his transaction.

currently this is part of the code that i have for the interface:

Code: Select all

print '<td height="184" colspan="3" width="463">' ;
        print '<form method = "POST" action="orderHandle.php"> ' ;
        print '<table border="2" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1">' ;
            print '<tr>' ;
            print '<td width="100%">' ;
                print '<table border="2" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1">' ;
                    print '<tr>' ;

                    //this is where the amount and quantity input is entered
                    print '<td width="47%" rowspan="2">' ;
                    print '&nbsp;<b><font face="Tahoma" size="2" color="#333300">meal&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :</font></b> <input type="text" name="meQTYa" size="2"><input type="text" name="meAMTa" size="3"><input type="submit" value="ME" name="button">' ;
                    print '<p>&nbsp;<b><font face="Tahoma" size="2" color="#333300">snack&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :</font></b> <input type="text" name="snQTYa" size="2"><input type="text" name="snAMTa" size="3"><input type="submit" value="SN" name="button"></p>' ;
                    print '<p>&nbsp;<b><font face="Tahoma" size="2" color="#333300">dessert&nbsp;&nbsp; :</font></b> <input type="text" name="deQTYa" size="2"><input type="text" name="deAMTa" size="3"><input type="submit" value="DE" name="button"></p>' ;
                    print '<p>&nbsp;<b><font face="Tahoma" size="2" color="#333300">beverage:</font></b> <input type="text" name="beQTYa" size="2"><input type="text" name="beAMTa" size="3"><input type="submit" value="BE" name="button"></td>' ;

                    //this is where the total amount and quantity is actively being updated depending on the number of inputs
                    print '<td width="53%">' ;
                    print '&nbsp;<b><font face="Tahoma" size="2" color="#333300">meal&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : </font></b><input type="text" name="meQTYb" size="3"><input type="text" name="meAMTb" size="3"><b><font face="Tahoma" size="2" color="#333300">=</font></b><input type="text" name="meTOTAL" size="3">' ;
                    print '<p>&nbsp;<b><font face="Tahoma" size="2" color="#333300">snack&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : </font></b> <input type="text" name="snQTYb" size="3"><input type="text" name="snAMTb" size="3"><b><font face="Tahoma" size="2" color="#333300">=</font></b><input type="text" name="snTOTAL" size="3"></p>' ;
                    print '<p>&nbsp;<b><font face="Tahoma" size="2" color="#333300">dessert&nbsp;&nbsp;&nbsp; : </font></b><input type="text" name="deQTYb" size="3"><input type="text" name="deAMTb" size="3"><b><font face="Tahoma" size="2" color="#333300">=</font></b><input type="text" name="deTOTAL" size="3"></p>' ;
                    print '<p>&nbsp;<b><font face="Tahoma" size="2" color="#333300">beverage :</font></b> <input type="text" name="beQTYb" size="3"><input type="text" name="beAMTb" size="3"><b><font face="Tahoma" size="2" color="#333300">=</font></b><input type="text" name="beTOTAL" size="3"></p></td>' ;

                    print '</tr>' ;
                    print '<tr>' ;
                    print '<td width="53%">&nbsp;<b><font face="Tahoma" size="2" color="#333300">total&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :</font></b> <input type="text" name="pTOTAL" size="6"></td>' ;
                    print '</tr>' ;
                print '</table>' ;
            print '</td>' ;
            print '</tr>' ;
            print '<tr>' ;
            print '<td width="100%" bgcolor = "#FF5B33">' ;
            print '<input type="submit" value="process order" name="button" style="float: right"><input type="reset" value="clear" name="B6" style="float: right"></td>' ;
            print '</tr>' ;
        print '</table>' ;
        print '</form>' ;
        print '</td>' ;
    print '</tr>' ;
you will notice that the form action redirects the user to "orderHandle.php". this is where i plan to handle the computations and stuff and then redirect the user to the interface again after performing the computations.

i have no clue on how to go about this at the moment. if you have better ideas or suggestions please help me out. thank you!
Last edited by gothica on Thu Sep 15, 2005 11:15 pm, edited 2 times in total.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

Code: Select all

header("Location: interface.php");
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
gothica
Forum Newbie
Posts: 15
Joined: Thu Sep 08, 2005 5:24 am

Post by gothica »

should i be using that on the orderHandle.php?

i would also like to know, how do i update my interface page's variables after orderHandle.php redirects the user back to the interface page.. coz what happens is that once i use the header function to redirect back to the interface page, the interface page's variables doesn't know the changes made by orderHandle.php

Code: Select all

for example:
       
       $qty = (no value yet)
       $amt = (no value yet)
       $total = (no value yet)

lets say, primarily (on a txtbox )$qty's value and $amt's value is null then user inputs a "4" and "4" respectively and clicks on the [ME] button
     -interface page-
       $qty = 4
       $amt = 4
       $total = (no value yet)

then the input is transerfered to orderHandle via $_POST["qty"] and $_POST["amt"]
     -orderHandle page-
       $total = $qty * $amt
      note: so result for this should be 16

then orderHandle redirects back to interface page...problem is, once the redirection happens the values on the variables are reseted to default.
     -interface page-
       $qty = (no value yet)
       $amt = (no value yet)
       $total = (no value yet)
do you know how can i still keep the inputted values?
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

Depends.

Are you storing the information in a database? If so, just take the information from the database and use the html fields value attribute to populate the information.

Code: Select all

<input type="text" name="amount" value="<? echo $value; ?>">
Or, you could post it in the URL, when doing your redirect

Code: Select all

// example, qty = 4, amt = 4

header("Location: interface.php?qty=".$_POST['qty']."&amt=".$_POST['amt']);
Then on the interface, your fields values would look like

Code: Select all

<input type="text" name="qty" value="<? echo $_GET['qty']; ?>">
<input type="text" name="amt" value="<? echo $_GET['amt']; ?>">
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Post Reply