Jump to content

phppup

Members
  • Posts

    789
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by phppup

  1. There are MANY, but let's work with CUTLETS.  (i'd list them all but it's lunchtime and we'd all get hungry.. LOL)

    By the way, I want to thank you all for your patience.  I do appreciate it.

    [Can you comment on MargateSteve's code.  It seems short and concise, but seems to have an unknown variable.]

  2. OKAY! Now I'm beginning to understand how PHP could have made my life easier.  However, I am WAY beyond that.  All the code has already been handwritten and the form has already submitted data INTO the DB.

     

    Now I have generated the identical form that comes up when I make a request for data FROM the DB.

     

    My difficulty at this point is that no VALUES are being placed in the form.

     

    ALL the data is generated INTo the database with HTML dropdown menus.

     

    I want it to get the info from the database so that the option that is saved in the database will be new default when the page is loaded, and will SHOW in the form.

     

    If I don't change it to the previous info it will update the database with the default option rather then the actual option.

     

     

  3. I'll do it manually (as long as it works) but I don't know what to write.

    How can I do it dynamically if every item has a different field name and I need the SUBMITTED value for EVERY item to become the NEW DEFAULT with the intention of the form being used to update data.

     

    example: customer ordered 1 chicken cutlet and now wants 3 instead.  I want to view the original order, verify that ONE was ordered, change the selection to 3, and UPDATe the record.

     

    If this cannot be handled in one page, I will gladly do it it two steps to avoid complications

  4. I've got this in my query:

     

    $result = mysql_query("SELECT * FROM pass WHERE id = 4 ")

    or die(mysql_error());

     

    $row = mysql_fetch_array( $result );

     

    And inside my form:

    echo "cutlets  <select name='chixcutlet' value=''>  ";

    echo "        <option value='0.00' selected>  --- </option>";

    echo "        <option value='1.00'>  1  </option>";

    echo "        <option value='2.00'>  2  </option>";

    echo "        <option value='3.00'>  3  </option>";

    echo " </select>";

     

    My form comes up fine, but no values are extracted from the DB.

     

    I want it to get the info from the database so that the option that is saved in the database will be new default when the page is loaded.

     

    If I don't change it to the previous info it will update the database with the default option rather then the actual option.

     

     

  5. I'm trying to pull up an identical form after submission by using its "id" and ECHO for the form lines.

     

    Question: What is the correct approach for ECHOing an HTML dropdown that is written as:

    <select name='chixcutlet' value='' >

            <option value='0.00' selected>  --- </option>

            <option value='1.00'>  1  </option>

            <option value='2.00'>  2  </option>

            <option value='3.00'>  3  </option>

    </select>

     

    I want it to get the info from the database so that the option that is saved in the database will be new default when the page is loaded.

     

    If I don't change it to the previous info it will update the database with the default option rather then the actual option.

  6. So I would have:

     

    $record_id = (isset($_POST['record_id'])) ? $_POST['record_id'] : '';

    //check for $record_id emptiness

    if(!empty($record_id))

    {

     

    "SELECT * FROM mytable WHERE id = $record_id "

    }

     

    Is that correct??  Am I missing any brackets or braces??

     

  7. I am able to view record numbers 22, 84, and 203 by exectuing my PHP script with the correct record ID.

     

    However, what I really want to do is have a simple form whereby I can input the desired record number and have it upload the data for me.

     

    I imagine it would look something like this:

    "SELECT * FROM mytable WHERE id = specified_record"

     

    but need a bit of guidance to get the HTML input fields 'name' into the PHP request.

  8. Ohhhhhhh, rest assured, I AM!!!!!

     

    Just noticed that certain numeric inputs in the database are shown as 3.00 and others as 3.  Then I realized some fields were SMALLINT and others were VARCHAR.

     

    I try not to post unless I'm really stumped, or short of time (because of the HOURS LOST chasing wrong solutions... LOL.  Nonetheless, I am enjoying the process.  Even at 3AM!

     

  9. I was gonna try something like that, but i GREATLY appreciate your response.  As a newbie it's VERY reassuring to know that something should work BEFORE attempting it.  Now if I run into trouble, I can at least feel confident that the effort is worthwhile, rather than the concept being impossible.

     

    Thanks

  10. My form has 40 fields, and I want to re-generate it to be reviewed as it was when submitted.  Next, I want to be able to UPDATE the forms values, where necessary.

     

    Is there an easy way to UPDATE the entire form from the reviewable version.  Is it smarter to update ONLY the specific items that need modification?

     

    Any examples would be helpful.

  11. My form has input1 and input2.  It then adds them and displays as TOTAL.  All 3 items have NAMES, and the form submission apparently grabs ALL the names to carry the info to the database.  Is a field for each of the 3 items REQUIRED for the database to accept the data?  I only need the two inputs for access.

  12. I know that I can fairly easily pull my data from the database and view it in a browser.

    I can also 'polish' it with some HTML or put it into a table.

    Can I get an item from a given VARIABLE to appear inside of an INPUT box, so that it looks the same as when it was initially submitted?

    Can it be done with a multiple choice SELECT dropdown, so that the item chosen is viewable again?

  13. TWO questions:

     

    I haven't actually CONNECTED and POSTED.  My form has two input fields that combine in a TOTAL field. I notice that the address bar is carrying TOTAL=input1+input2 when it TRIES to connect.  Do I need to include

    the TOTAL field in the database if the info is NOT relavant data? the strg and chick TOTALS? 

     

    Will the database accept PARTIAL data from a form that has 25 field with only 6 being populated for testing?

     

  14. My form begins with:

    <form name="orderpage" action="passpost.php" method="post">

    <table>

     

    OOPS!!! never mind.  Now I feel stupid.  Been staring at this for 6 hours, and when I cut and pasted the code I noticed I had 2 form tags, so the submit was actually outside the process.  Now I'm fine.

     

    This is why I'm just a PUP (or PUPIL) at this point.  Sometimes you just need a second set of eyes to see it!

     

    Thanks for the assist.

     

  15. The HTML looks something like this all the way throuogh:

    <tr><td>

          <select name="brisket">

            <option value="0.00" selected>  --- </option>

            <option value="1.00">  1  </option>

            <option value="2.00">  2  </option>

            <option value="3.00">  3  </option>

            <option value="4.00">  4  </option>

            <option value="5.00">  5  </option>

            <option value="6.00">  6  </option>

            <option value="7.00">  7  </option>

            <option value="8.00">  8  </option>

            <option value="9.00">  9  </option>

            <option value="10.00">10  </option>

          </select></td><td>BRISKET OF BEEF</td><td>32.00 LB</td><td>ujiujjpooj</td><td> <!-- FILLER --> </td>

          <td>

          <select name="carrots">

            <option value="0.00" selected>  --- </option>

            <option value="1.00">  1  </option>

            <option value="2.00">  2  </option>

            <option value="3.00">  3  </option>

            <option value="4.00">  4  </option>

            <option value="5.00">  5  </option>

            <option value="6.00">  6  </option>

            <option value="7.00">  7  </option>

            <option value="8.00">  8  </option>

            <option value="9.00">  9  </option>

            <option value="10.00">10  </option>

          </select></td><td>CARROTS</td><td>

     

    and my PHP is here:

     

    <?php   

    require('connection.php');

     

    mysql_connect("$hostname", "$username", "$password") or die ('Unable to connect to database!);

    mysql_select_db("$database") or die('Could not connect to db: ' . mysql_error());

     

    if(isset($_POST['action']) && $_POST['action'] == 'submitform')

    {

    $roastturkey = $_POST['roastturkey'];

    $broccoli = $_POST['broccoli'];

    $brisket = $_POST['brisket'];

    $carrots = $_POST['carrots'];

    $EZchix_sum= $_POST['EZchix_sum'];

    $chixcutlet = $_POST['chixcutlet'];

    $chixfingers = $_POST['chixfingers'];

    $strgbalmond_sum=$_POST['strgbalmond_sum'];

    $strgbalmond1 = $_POST['strgbalmond1'];

    $strgbalmond2 = $_POST['strgbalmond2'];

    $strgbalmond3 = $_POST['strgbalmond3'];

    }

     

    $sql = "INSERT INTO dinnertable (roastturkey,broccoli,brisket,carrots,chixcutlet,chixfingers,strgbalmond1,strgbalmond2,strgbalmond3) VALUES

    ('','$roastturkey','$broccoli','$brisket','$carrots','$chixcutlet','$chixfingers','$strgbalmond1','$strgbalmond2','$strgbalmond3')";

     

    $result=mysql_query($sql);

    // if successfully insert data into database, displays message "Successful".

    if($result){

    echo "Successful";

    else {

    echo "ERROR";

    }

    >

     

    I just noticed that the feature for the TOTAL chicken and strgbalmond were being carried in the address bar.  They are not important for my database, but maybe i needfields for them anyway????

     

    Anditionally, I created a simple form with one field and a submit and ran it through my insert script and I got a successful connection and error message.  Then I re-wrote my button on this form, and still no connection.

     

    Is the something about HTML 'selects' that I'm missing?  Or a PHP comma or quote??

     

  16. I have a form with a table that contains ONLY dropdown menus for users to select quantities from 25 dinner items.  It contains some Javascript, but nothing fancy.  In an effort to establish my database and TEST to see how some PHP functions might respond so I could improve my form, I created a mini version of the db in MySQL.

     

    But when I click the submit button, the page blinks, the address bar fills with field names, but there is no connect.  No error messages.  No data transfer.  NO NOTHING!

     

    I searched the web and copied a form and plugged it in (an html form, a php insert file, and a MySQL database) and it worked fine.  I peared down my page to mirror it, and still, no success.

     

    What little detail am I missing??  If I have 25 fields but create a db for the first 6, should it function?

    If I reduce it and try to re-use the same db, am I persuing a problem?

    I've tried error trapping and changing the form inputs, but it just still doesn't connect.

     

    Please help!

  17. As long as I'm logged in (although this may be more to the topic of 'table structure'), my table has fields for small, medium, and large blue candles and small, medium, and large pink candles.

    When an order is placed, the quantity requested is INSERTED into the correct field.

     

    Am I creating unnecessary overhead?

     

    Is there a way to have just one field for blue candles and one for pink, whereby the INSERT will record a customer request for 4 candles that are the small size?  And how would I retrieve the data when I want to know both the total number of candles and their sizes.

     

    Note: the order form has radio buttons for the sizes, so a single order can only accept a single size per submission.  Not sure if there's a simple way around that, but I'm learning more each day.

     

    Thanks in advance.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.