Professional Web Applications Themes

Array maybe? Or many SQL insert queries - PHP Development

Hi everyone, here's what I'm doing. As of right now, I don't have anything implemented, but here's what I need to do. I have a web page, with a drop down list of hotels, an input box for the users frequent hotel number, and a add button. At the bottom of the page is a update and continue button to move the user to the next page with more options. What my boss wants is, when someone puts in a number, and clicks add, he wants it to take that number and put it below the box, all on the ...

  1. #1

    Default Array maybe? Or many SQL insert queries

    Hi everyone, here's what I'm doing.

    As of right now, I don't have anything implemented, but here's what I
    need to do.

    I have a web page, with a drop down list of hotels, an input box for
    the users frequent hotel number, and a add button. At the bottom of
    the page is a update and continue button to move the user to the next
    page with more options.

    What my boss wants is, when someone puts in a number, and clicks add,
    he wants it to take that number and put it below the box, all on the
    fly. I know I could do this through repeated sql insert querys, but I
    was wondering if I could just put them into an array, then update the
    database with one query after the user clicks the update and continue
    button at the bottom, to get them to the next page?

    I will need to use this same outline for the this page, plus the next
    2 pages in sequence for car and flyer numbers.

    Or, if anyone has a better way of an array or sql queries, that will
    work as well. :-)

    Thanks,

    Jake McHenry
    Nittany Travel MIS Coordinator
    http://www.nittanytravel.com
    Jake Guest

  2. #2

    Default Re: [PHP] Array maybe? Or many SQL insert queries

    Jake McHenry wrote:
     

    This sounds like something javascript can fix. If you can be a bit more
    precise "below the box" doesn't mean much. What box? Is it a big green
    box? Blue box? Box of boxes?

    If you want "on the fly" then its javascript. For php to work, you'd
    have to send a request to the server, which would kill your "on the fly"
    part.


    --
    Burhan Khalid
    phplist[at]meidomus[dot]com
    http://www.meidomus.com
    Burhan Guest

  3. #3

    Default RE: [PHP] Array maybe? Or many SQL insert queries

    > -----Original Message----- 
    > here's what I  
    > input box for  [/ref]
    of  
    > to the next  
    > clicks add,  
    > all on the  
    > querys, but I  
    > update the  
    > and continue  
    >
    > This sounds like something javascript can fix. If you can be
    > a bit more
    > precise "below the box" doesn't mean much. What box? Is it a
    > big green
    > box? Blue box? Box of boxes?
    >
    > If you want "on the fly" then its javascript. For php to work, you'd[/ref]
     


    I don't know why I said on the fly.. Lol..

    The box I'm referring to is the input field box. I just need what's
    submitted via the input field and add button to show up in a list
    below the input box, to show the account numbers that were entered. I
    can either insert them into the database each time the add button is
    clicked, or my preference if possible, put them in an array of some
    kind then submit them all at once. To get a picture of what I want...:




    Site Logo
    ______________
    |______________| ADD


    Submit and Continue Submit and Exit




    That's basically what this page looks like. What I need is when the
    person inputs the account number in the input box, and clicks add, it
    needs to refresh the page with the added number below that box, then
    again for each number they enter.

    Like I said, I can do this with multiple accesses to the database, but
    I would like to know of a way I could submit them all at once instead
    of multiple accesses to the database.


    Let me know if you need more info.



    Thanks,

    Jake McHenry
    Nittany Travel MIS Coordinator
    http://www.nittanytravel.com
    Jake Guest

  4. #4

    Default Re: [PHP] Array maybe? Or many SQL insert queries

    I noticed that Message-ID: <009b01c3a068$c0e59460$12a2e518FAMILY> from
    Jake McHenry contained the following:
     

    You'd have to have multiple accesses whichever way you do it, I don't
    think you can INSERT more than one row at a time.

    Also if you output to screen (saving the value as a session variable for
    instance) the customer might think the value is already recorded. and
    quit withut confirming the data.

    Safer to add each one as it's entered I'd say. Maybe echo to the screen
    with an option to edit?

    --
    Geoff Berrow
    It's only Usenet, no one dies.
    My opinions, not the committee's, mine.
    Simple RFDs http://www.ckdog.co.uk/rfdmaker/
    Geoff Guest

  5. #5

    Default Re: [PHP] Array maybe? Or many SQL insert queries

    Jake McHenry wrote: 
    >>
    >>here's what I
    >> 
    >>
    >>input box for
    >> [/ref]
    >
    > of

    >>
    >>to the next
    >> 
    >>
    >>clicks add,
    >> 
    >>
    >>all on the
    >> 
    >>
    >>querys, but I
    >> 
    >>
    >>update the
    >> 
    >>
    >>and continue
    >> 
    >>
    >>This sounds like something javascript can fix. If you can be
    >>a bit more
    >>precise "below the box" doesn't mean much. What box? Is it a
    >>big green
    >>box? Blue box? Box of boxes?
    >>
    >>If you want "on the fly" then its javascript. For php to work, you'd[/ref]
    >

    > I don't know why I said on the fly.. Lol..
    >
    > The box I'm referring to is the input field box. I just need what's
    > submitted via the input field and add button to show up in a list
    > below the input box, to show the account numbers that were entered. I
    > can either insert them into the database each time the add button is
    > clicked, or my preference if possible, put them in an array of some
    > kind then submit them all at once. To get a picture of what I want...:
    >
    >
    >
    >
    > Site Logo
    > ______________
    > |______________| ADD
    >
    >
    > Submit and Continue Submit and Exit
    >
    >
    >
    >
    > That's basically what this page looks like. What I need is when the
    > person inputs the account number in the input box, and clicks add, it
    > needs to refresh the page with the added number below that box, then
    > again for each number they enter.[/ref]

    You can attach a javascript function to the onclick event of the Add
    button that populates your drop down. Of course, this assumes that you
    have a predefined array of all possible values (in javascript) that the
    user can enter.

    However, if your user can arbitrarily enter values, and all you need to
    do is "add" them to the drop down list, then some simple javascript DOM
    is all you need. Then when the user clicks on the Submit and Continue
    button, use php to read the dropdown array (appending [] to the name
    attribute's value will help -- like this <select name="foo[]"> then
    $_POST['foo'][0] would hold the value of your selected index).

    If you are not a big fan of javascript + DOM (this is, after all, a PHP
    list) -- you can use PHP to dynamically populate the dropdown by
    appending the value of the entered box to the array. Something along the
    lines of (untested):

    $textbx = isset($_POST['textbx']) ? $_POST['textbx'] : NULL;
    $menu = array();
    if ($textbx != NULL)
    {
    $menu['somevalue'] = $textbx;
    } else { echo "<select name=\"chooser[]\"><option value=\"NULL\"
    selected=\"selected\">Please enter a value</option></select>";
    }

    /* we now assume that the array was populated */
    echo "<select name=\"chooser[]\">\n";
    echo "<option value=\"NULL\" selected=\"selected\">Value Entered
    Below</option>\n";
    while(list($k,$v) = each($menu))
    {
    echo "<option value=\"".$k."\">".$v."</option>\n";
    }
    echo "</select>";


    Hope this helps.

    --
    Burhan Khalid
    phplist[at]meidomus[dot]com
    http://www.meidomus.com
    Burhan Guest

  6. #6

    Default RE: [PHP] Array maybe? Or many SQL insert queries

    > -----Original Message----- 
    > >
    > > of
    > >  [/ref][/ref]
    you'd 
    > > I don't know why I said on the fly.. Lol..
    > >
    > > The box I'm referring to is the input field box. I just need[/ref][/ref]
    what's  
    > entered. I  
    > button is  [/ref]
    some  
    > I want...: 
    > Submit and Exit [/ref]
    the  
    > clicks add, it  
    > box, then  
    >
    > You can attach a javascript function to the onclick event of the Add[/ref]
     
    Continue  
     

    I'm not making a drop down box, I just want the contents of what is
    added to be displayed on the page.

    I got all of this done by creating an array and storing it in a
    session variable.

    Here's the code...

    if ($_POST['2_Add'] != "")
    {
    if (($_POST['Frequent_Flyer_Program'] != "") &&
    ($_POST['Frequent_Flyer_Number'] != ""))
    {
    $array = array();
    $new =
    "{$_POST['Frequent_Flyer_Program']},{$_POST['Frequent_Flyer_Number']}"
    ;
    $old = $_SESSION['Frequent_Flyer'];
    $array = array_merge($old, $new);
    $_SESSION['Frequent_Flyer'] = $array;
    }
    header("Location: profile2.php");
    }



    The only dilema I have now is... How can I allow the user to remove
    entries from this array if they make a mistake?

    On the other pages where the add button is, and the list, I have a
    foreach loop that explodes the array and prints it out. Simple... Now
    I just need a way for them to remove a certain entry.. Hopefully this
    is an easy addition.

    Thanks

    Jake
    Jake Guest

Similar Threads

  1. Query of queries: insert into another datasource
    By Arielladog in forum Coldfusion Database Access
    Replies: 5
    Last Post: July 24th, 02:14 AM
  2. insert values in an array
    By Rob in forum PHP Development
    Replies: 2
    Last Post: February 5th, 07:14 PM
  3. Need help with repetitive Insert queries, help me consolidate...
    By Craig in forum Microsoft SQL / MS SQL Server
    Replies: 4
    Last Post: July 31st, 11:59 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139