Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 06-11-2006, 09:18 PM Form Data Question.
daddy2five's Avatar
Skilled Talker

Posts: 77
Name: Daniel
Location: Stony Point , Noth Carolina
Trades: 0
Hi everyone, It's been awhile since my last post. I'm currently working on a project that will make my life a bit easier. I am in shipping and I have to pick tickets and build pallets that have different products on them for my company. I am creating a script that will generate a printable form. It has 3 parts. I have the first two parts done, but I'm stumped on the third. I don't know how to write the code to do what I need with the form data. I will post the entire thing here and explain it so you all can take a look at it.

OK here is the first step, a simple html doc. that passes the data to a php script that generates the correct number of fields on it to enter in the different part numbers and their quantities.
HTML Code:
<HTML>
<HEAD>
<TITLE>Mixed Pallet Form (Step 1)</TITLE>
</HEAD>
<BODY>
<CENTER><H1>Mixed Pallet Form (Step 1)</H1></CENTER>
<FORM method="POST" action="mixedpallet1.php">
<P>Sales Order Number:<br><INPUT type="text" name="sales_order_number"

size=10></P>
<P>How many different products?: <br><INPUT type="text" name="products"

size=5></P>
<INPUT type="submit" value="Go to step 2">
</FORM>
</BODY>
</HTML>
Here is the 2nd part which is the php script that generates another form with the right amout of fields for the form. From which I want to make the printable form.
PHP Code:
<HTML>
<HEAD>
<TITLE>Create a Mixed Pallet Form: Step 2</TITLE>
</HEAD>
<BODY>
<H1>Mixed Pallet Form For Sales Order#
<?php echo "$_POST[sales_order_number]?></H1>
<FORM method="POST" action="mixedpallet2.php">
<INPUT type="hidden" name="sales_order_number" value="<?php echo

"$_POST[sales_order_number]"?> ">


<?php
for ($i $i $_POST[products]; $i++) {
    echo 
"
<table cellspacing=5 cellpadding=5>
<tr>
<td valign=top><strong>Item:</strong>
<td valign=top><INPUT type='text' name='item' size=25 maxlength=30></td>
<td valign=top><strong>Qty:</strong><INPUT type='text' name='qty' size=3 maxlength=3>
</tr>"
;
}
?>
<tr>
<td align=center colspan=3>
<INPUT type="submit" value="Generate Mix Pallet Form"></td>
</tr>
</table>
</FORM>
</BODY>
</HTML>
The last part is the part I am stumped on. I want to print the different part numbers and their quantities in a table. and then add the quantities and post them under a "total" section of the printable form. I'm really weak when it comes arrays. I have been reading up, and looking on the net. I have tried different things, but I am still stumped. I really would appreciate any help someone could give me on this. Thanks for all the help in advance.
__________________
What is Yuwie?

Please login or register to view this content. Registration is FREE
daddy2five is offline
Reply With Quote
View Public Profile Visit daddy2five's homepage!
 
 
Register now for full access!
Old 06-11-2006, 10:41 PM Re: Form Data Question.
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
Trades: 0
Change your last form like below so you will have unique entries for each product and build an array:

PHP Code:
<html>
  <head>
    <title>Create a Mixed Pallet Form: Step 2</title>
  </head>
  <body>
    <h1>Mixed Pallet Form For Sales Order#<?php echo $_POST['sales_order_number'] ; ?></h1>
    <form method="post" action="mixedpallet2.php">
      <input type="hidden" name="sales_order_number" value="<?php echo $_POST['sales_order_number']; ?>" />
      <input type="hidden" name="products" value="<?php echo $_POST['products']; ?>" />
      <table cellspacing=5 cellpadding=5>
<?php
  
  
for ($i $i < (int)$_POST['products']; $i++) {
    echo 
"
        <tr>
          <td valign=top><strong>Item: 
$i:</strong>
          <td valign=top><input type='text' name='item[
$i]' size=25 maxlength=30></td>
          <td valign=top><strong>Qty:</strong><input type='text' name='qty[
$i]' size=3 maxlength=3>
        </tr>"
;
  }
  
?>
        <tr>
          <td align=center colspan=3><input type="submit" value="Generate Mix Pallet Form"></td>
        </tr>
      </table>
    </form>
  </body>
</html>
Then your next page will have matching content arrays:

PHP Code:
<?php
  
  $i 
0;
  while(
$i count((int)$_POST['products'])) {
    
    echo 
$_POST['item'][$i]; // Contains item number
    
    
echo $_POST['qty'][$i]; // Contains qty number for item above
    
    
$i++;
  }
  
?>
__________________

<mgraphic /> - I don't have a solution but I admire the problem.

Last edited by mgraphic; 06-11-2006 at 10:48 PM..
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 06-11-2006, 10:45 PM Re: Form Data Question.
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
Trades: 0
I forgot, to add the totals, add the following modification:

PHP Code:
<?php
  
  $i 
0;
  
$total 0;
  while(
$i count((int)$_POST['products'])) {
    
    echo 
$_POST['item'][$i]; // Contains item number
    
    
echo $_POST['qty'][$i]; // Contains qty number for item above
    
    
$total += (int)$_POST['qty'][$i];
    
    
$i++;
  }
  
  echo 
'Total: ' $total;
  
?>
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 06-12-2006, 07:50 AM Re: Form Data Question.
daddy2five's Avatar
Skilled Talker

Posts: 77
Name: Daniel
Location: Stony Point , Noth Carolina
Trades: 0
Mgraphic, Thank you again. I would give you more talkupation, but this website wont let me. Many many thanks to you.
It works , but it wont print the entire list. It prints out the first item and quantity and then stops. What can I do to fix this?
__________________
What is Yuwie?

Please login or register to view this content. Registration is FREE

Last edited by daddy2five; 06-12-2006 at 08:59 AM..
daddy2five is offline
Reply With Quote
View Public Profile Visit daddy2five's homepage!
 
Old 06-12-2006, 10:40 AM Re: Form Data Question.
ibbo's Avatar
Super Spam Talker

Posts: 880
Location: Leeds UK
Trades: 0
Change "while($i < count((int)$_POST['products']))" for "while($i < $_POST['products'])" as (count (cast (number)) fails to returna bvalue > 1 (or so it seems).

Strip the cast and count away and you get your results.

I had to edit it slight;y to output any boxes at all. I used this to get some boxes on screen empty ($_POST['products']) ? $_POST['products']=5 : '';.

Hope that sorts it for you

Ibbo
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

Linux user #349545 :
(GNU/Linux)iD8DBQBAzWjX+MZAIjBWXGURAmflAKCntuBbuKCWenpm XoA7LNydllVQOwCf
ibbo is offline
Reply With Quote
View Public Profile Visit ibbo's homepage!
 
Old 06-12-2006, 11:03 AM Re: Form Data Question.
daddy2five's Avatar
Skilled Talker

Posts: 77
Name: Daniel
Location: Stony Point , Noth Carolina
Trades: 0
Appreciate your help it is working now, Now all I have to do is make it look good. thanks for your time. Talkupation for you.
__________________
What is Yuwie?

Please login or register to view this content. Registration is FREE
daddy2five is offline
Reply With Quote
View Public Profile Visit daddy2five's homepage!
 
Reply     « Reply to Form Data Question.
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.17266 seconds with 12 queries