Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Page 2 of 3 FirstFirst 1 2 3 LastLast
Results 11 to 20 of 24
  1. #11
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,975
    Member #
    5580
    Liked
    760 times
    You're at a point where you should do 2 things for us.

    1) Give us the URL so we can see your form.
    2) Post all or part of your PHP code so we can see how you
    are accessing your MySQL and creating your form ...
    (X-out the passwords and stuff so nobody can see your MySQL account info).

    This will really help us to see what you are doing.


  2.  

  3. #12
    Member
    Join Date
    Jun 2007
    Location
    Scotts Valley, CA
    Posts
    49
    Member #
    15405
    So the URL for the order form is:

    http://www.sessions.info/distributor/HTML/orderForm.php

    The database used to generate it has the following fields:
    1. Season
    2. Style #
    3. Style Name
    4. Colorway 1
    5. Colorway 2
    6. Colorway 3
    7. Colorway 4
    8. Size 1
    9. Size 2
    10. Size 3
    11. Size 4
    12. Size 5
    13. Size 6
    14. Size 7

    The PHP that generates the form is basically two different sets of code.

    1. Cell Generator
    PHP Code:
    <?
    function generateCells()
    {
    global 
    $result;
    global 
    $i;
    $COL1 mysql_result($result$iCOL1);
    $STNO mysql_result($result$iSTNO);
    if (
    mysql_result($result$iSIZ1)==NULL)
        {
        echo 
    "<td></td>";
        }
    else
        {
        echo 
    "<td><input type='text' name='$STNO$COL1' /></td>";
        }
    if (
    mysql_result($result$iSIZ2)==NULL)
        {
        echo 
    "<td></td>";
        }
    else
        {
        echo 
    "<td><input type='text' /></td>";
        }
    if (
    mysql_result($result$iSIZ3)==NULL)
        {
        echo 
    "<td></td>";
        }
    else
        {
        echo 
    "<td><input type='text' /></td>";
        }
    if (
    mysql_result($result$iSIZ4)==NULL)
        {
        echo 
    "<td></td>";
        }
    else
        {
        echo 
    "<td><input type='text' /></td>";
        }
    if (
    mysql_result($result$iSIZ5)==NULL)
        {
        echo 
    "<td></td>";
        }
    else
        {
        echo 
    "<td><input type='text' /></td>";
        }
    if (
    mysql_result($result$iSIZ6)==NULL)
        {
        echo 
    "<td></td>";
        }
    else
        {
        echo 
    "<td><input type='text' /></td>";
        }
    if (
    mysql_result($result$iSIZ7)==NULL)
        {
        echo 
    "<td></td>";
        }
    else
        {
        echo 
    "<td><input type='text' /></td>";
        }
    echo 
    "<td><input type='text' value='0' /></td>";
    }
    ?>
    2. Order Form Generator
    PHP Code:
    <?
    include "mySQLConnect.php";
    include 
    "cellGenerator.php";
    connectToDB($username$password);
    @
    mysql_select_db("session_distributors") or die("Unable to select database");
    $query "SELECT * FROM StyleList WHERE SEAS = 'SP08'";
    $result mysql_query($query) or die (mysql_error());
    echo 
    "<form method='post' action='PHP/validate.php'><table>";
    while (
    $row mysql_fetch_array($resultMYSQL_ASSOC))
        {
        echo 
    "<tr>";
        echo 
    "<td></td><td></td><td></td>";
        echo 
    "<td>";
        echo 
    mysql_result($result$iSIZ1);
        echo 
    "</td><td>";
        echo 
    mysql_result($result$iSIZ2);
        echo 
    "</td><td>";
        echo 
    mysql_result($result$iSIZ3);
        echo 
    "</td><td>";
        echo 
    mysql_result($result$iSIZ4);
        echo 
    "</td><td>";
        echo 
    mysql_result($result$iSIZ5);
        echo 
    "</td><td>";
        echo 
    mysql_result($result$iSIZ6);
        echo 
    "</td><td>";
        echo 
    mysql_result($result$iSIZ7);
        echo 
    "</td></tr>";
        echo 
    "<tr><td><input value='";
        echo 
    mysql_result($result$iSTNO);
        echo 
    "' /></td><td><input value='";
        echo 
    mysql_result($result$iSTNA);
        echo 
    "'/></td>";
        if(
    mysql_result($result$iCOL1) != NULL)
            {
            echo 
    "<td><input value='";
            echo 
    mysql_result($result$iCOL1);
            echo
    "'/></td>";
            
    generateCells();
            }
        
        if(
    mysql_result($result$iCOL2) != NULL)
            {
            echo 
    "<tr><td>";
            echo 
    mysql_result($result$iSTNO);
            echo 
    "</td><td>";
            echo 
    mysql_result($result$iSTNA);
            echo 
    "</td><td>";
            echo 
    mysql_result($result$iCOL2);
            
    generateCells();
            }
        if(
    mysql_result($result$iCOL3) != NULL)
            {
            echo 
    "<tr><td>";
            echo 
    mysql_result($result$iSTNO);
            echo 
    "</td><td>";
            echo 
    mysql_result($result$iSTNA);
            echo 
    "</td><td>";
            echo 
    mysql_result($result$iCOL3);
            
    generateCells();
            }
        if(
    mysql_result($result$iCOL4) != NULL)
            {
            echo 
    "<tr><td>";
            echo 
    mysql_result($result$iSTNO);
            echo 
    "</td><td>";
            echo 
    mysql_result($result$iSTNA);
            echo 
    "</td><td>";
            echo 
    mysql_result($result$iCOL4);
            
    generateCells();
            }
        
        
    $i++; 
        }
    echo 
    "</table></form>";
    ?>
    mySQLConnect.php is just a function for connecting to the database. Thanks all for your help with this...

    Cheers,

    K.

  4. #13
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,975
    Member #
    5580
    Liked
    760 times
    Also ...
    You'll need a submit button at the bottom ...
    <input type='submit' name='submit' value='Submit'>

    Not familiar with clothing, I'm not sure what data that's shown is needed.
    Or, what the user will be filling-out in the form.

    I can see now how hard this will be for all of us that don't understand
    what the data even means ...

    Let's just look at one thing like this item 102838

    What do the various fields mean and what would the user be
    filling-out on the form for that one item? It looks to me like that
    item has 4 lines, but only the top line is a text box that can be edited.

    Maybe you can describe what I (the user) would be doing with item: 102838


  5. #14
    Member
    Join Date
    Jun 2007
    Location
    Scotts Valley, CA
    Posts
    49
    Member #
    15405
    Thanks for your reply, ML. So the form as it stands isn't exactly how it should necessarily be at the end of the day. "102838" corresponds to a style or part number and identifies the particular garment "Cab Pinstripe" and identifies that the garment is one of that style.

    "140" identifies which color of style "102838" we're talking about. Then the boxes (which we actually want the user to fill out) correspond to the size of style "102838" in color "140" that the user wants. The column of zeroes will eventually be a price and total column.

    You'll enter in what quantities of what sizes you want, the form will total with each change, both by row and by overall quantities (to be added to the bottom). Then you'll hit "Submit" (to be added once I've figured out what exactly I want to have "Submit" do-- my problem now), the form will check to make sure you're ordering the minimum quantity of each style/color (for example, that you've ordered at least 6 units of 102838 in 140, or else 0 units). If not, you'll be asked to fix the form before submitting it. If so, you'll be shown a copy of your order form filled out, then asked to hit confirm, at which point the data will upload to the database.

    Hope this clarifies things!

    Again, thanks for your help.

    Cheers,

    K.

    Right now, the fact that the top line is a text box that can be edited is just me messing around with ways to get the data into the database.

  6. #15
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,975
    Member #
    5580
    Liked
    760 times
    I can't see any Javascript way to dynamically update the total boxes on-the-fly.

    Is it necessary to have the form update each time a box is changed, or can
    there be a "re-calculate" button at the bottom?

    The problem is, because the form is dynamic to begin with, there is no way to
    write a Javascript that can be flexible enough to deal with all the textboxes ...
    at least no way that I know.

    If PHP was used, the totals could be done, but a refresh of the page would
    be necessary each time (like a "re-calculate button).

    In any event, each item you are generating (each textbox) needs a name
    or ID associated with it, for sending the variables to the PHP script.


  7. #16
    Member
    Join Date
    Jun 2007
    Location
    Scotts Valley, CA
    Posts
    49
    Member #
    15405
    Thanks again for the speedy reply, ML.

    I'm thinking that the way to go is to worry about the Javascript (or whatever validation method) later.

    I'd also been thinking about designating the inputs with the name "style#+colorway+size#" using cellGenerator.php. That's not too difficult.

    What I have a hard time wrapping my head around is migrating this into the table where I'm storing the orders. This table has the fields:
    1. Style #
    2. Colorway
    3. Size 1
    4. Size 2
    5. Size 3
    6. Size 4
    7. Size 5
    8. Size 6
    9. Size 7

    I want it set up like this, because ultimately these things get outputted as flat files before being uploaded into our production management software. We have an existing program that will handle the upload for data presented in this format and would like to continue to use that program.

    So at this point, my worry is specifically getting the data from my form into my database table when the user hits "submit" or "confirm".

    Cheers,

    K.

  8. #17
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,975
    Member #
    5580
    Liked
    760 times
    Indicate the format of the "flat-file" table. Is it a .csv file (for Excel?)

    Also, put a size property in your text boxes so your form isn't so huge.

    If you can use PHP to create your form and give the
    textboxes names like, item1[], then size1[]
    the next item would be item2[], size2[]

    This will end up in PHP with an array for each item.
    size2[0], size2[1], etc.

    So we can loop through the variables and create the flat-file database.

    I'm just not good at explaining it and I can't find a good example either.

    The key is, you won't know how many items are on each form, so the
    PHP script needs to loop until it can't find anymore, processing them along
    the way.


  9. #18
    Member
    Join Date
    Jun 2007
    Location
    Scotts Valley, CA
    Posts
    49
    Member #
    15405
    Thanks, ML.

    It's starting to get a bit clearer to me, just from messing around with it and thinking about it. Once I've found a solution that works, I'll make sure to post it, so others can benefit!

    Cheers,

    K.

  10. #19
    Member
    Join Date
    Jun 2007
    Location
    Scotts Valley, CA
    Posts
    49
    Member #
    15405
    So I took a couple days off and came back a bit muddier again... I had a lot of trouble getting the code to name the text boxes as elements in an array, and I'm going to try again with the names stored in a MySQL database...

    If anyone has any brainstorms, I'd be up for it....
    Cheers,

    K.

  11. #20
    Member
    Join Date
    Jun 2007
    Location
    Scotts Valley, CA
    Posts
    49
    Member #
    15405
    So, I've gotten the form worked up a bit more, and now I'm trying to get the backend figured out to validate it. I'm having a bit of trouble looping the $_POST variables. To refresh the form is at:
    http://www.sessions.info/distributor/HTML/orderForm.php

    Here's what the php on validate.php looks like:
    PHP Code:
    <?
    while($_POST[STNO]!= NULL)
    {
    echo 
    $_POST [STNO][$i];
    echo 
    $_POST [CWAY][$i];
    echo 
    $_POST [SIZ1][$i];
    echo 
    $_POST [SIZ2][$i];
    echo 
    $_POST [SIZ3][$i];
    echo 
    $_POST [SIZ4][$i];
    echo 
    $_POST [SIZ5][$i];
    echo 
    $_POST [SIZ6][$i];
    echo 
    $_POST [SIZ7][$i];
    echo 
    "<br />";
    $i++;
    }
    ?>
    It seems to be looping endlessly... How do I make it stop?

    Cheers,

    K.


Page 2 of 3 FirstFirst 1 2 3 LastLast

Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 08:38 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com