Jump to content

phppup

Members
  • Posts

    862
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by phppup

  1. I've been refreshing ALL day.

     

     

     

    I have a dropdwon menu coded as follows"

    echo "<tr><td>";

    echo "<select name='roastturkey'>";

    echo        "<option value='0.00'  " . ($array['roastturkey'] == 0 ? 'selected="selected"' : '') . ">0</option>";

    echo        "<option value='1.00'  " . ($array['roastturkey'] == 0 ? 'selected="selected"' : '') . ">1</option>";

    echo        "<option value='2.00'> " . ($array['roastturkey'] == 0 ? 'selected="selected"' : '') . ">2</option>";

    echo        "<option value='3.00'> " . ($array['roastturkey'] == 0 ? 'selected="selected"' : '') . ">3</option>";

    echo        "<option value='4.00'> " . ($array['roastturkey'] == 0 ? 'selected="selected"' : '') . ">4</option>";

    echo        "<option value='5.00'> " . ($array['roastturkey'] == 0 ? 'selected="selected"' : '') . ">5</option>";

    echo        "<option value='6.00'> " . ($array['roastturkey'] == 0 ? 'selected="selected"' : '') . ">6</option>";

    echo        "<option value='7.00'> " . ($array['roastturkey'] == 0 ? 'selected="selected"' : '') . ">7</option>";

    echo        "<option value='8.00'> " . ($array['roastturkey'] == 0 ? 'selected="selected"' : '') . ">8</option>";

    echo        "<option value='9.00'> " . ($array['roastturkey'] == 0 ? 'selected="selected"' : '') . ">9</option>";

    echo        "<option value='10.00'>  " . ($array['roastturkey'] == 0 ? 'selected="selected"' : '') . ">10</option>";

    echo        "      </select></td><td rowspan='2'>ROAST TURKEY</span></td><td rowspan='2'>7.00 LB</span></td> ";

     

     

    And a database quierie after connecting is:

     

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

     

    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 form 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 when re-submitted.

     

     

    Record 4 has 10 as the value for the 'roastturkey'.

    I've changed it to record 5 which has a value of 5, but the dropdown does NOT change.

     

  2. OKAY, the dropdown is now populated with number from 0 thru 10.

     

    The database quierie after connecting is:

     

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

     

    Record 4 has 10 as the value for the 'roastturkey'.

    I've changed it to record 5 which has a value of 5,

     

    Yet the dropdown STILL does NOT change to reflect the stored value in the database  :-(

     

     

  3. That was the first thinig I did.  I mean, I'm not totally ignorant.  I switched a few numbers and this is what I have now:

    echo "<tr><td>";

    echo "<select name='roastturkey'>";

    echo        "<option value='0.00'  " . ($array['roastturkey'] == 0 ? 'selected="selected"' : '') . ">0</option>";

    echo        "<option value='1.00'  " . ($array['roastturkey'] == 0 ? 'selected="selected"' : '') . ">1</option>";

    echo        "<option value='2.00'> " . ($array['roastturkey'] == 0 ? 'selected="selected"' : '') . ">2</option>";

    echo        "<option value='3.00'> " . ($array['roastturkey'] == 0 ? 'selected="selected"' : '') . ">3</option>";

    echo        "<option value='4.00'> " . ($array['roastturkey'] == 0 ? 'selected="selected"' : '') . ">4</option>";

    echo        "<option value='5.00'> " . ($array['roastturkey'] == 0 ? 'selected="selected"' : '') . ">5</option>";

    echo        "<option value='6.00'> " . ($array['roastturkey'] == 0 ? 'selected="selected"' : '') . ">6</option>";

    echo        "<option value='7.00'> " . ($array['roastturkey'] == 0 ? 'selected="selected"' : '') . ">7</option>";

    echo        "<option value='8.00'> " . ($array['roastturkey'] == 0 ? 'selected="selected"' : '') . ">8</option>";

    echo        "<option value='9.00'> " . ($array['roastturkey'] == 0 ? 'selected="selected"' : '') . ">9</option>";

    echo        "<option value='10.00'>  " . ($array['roastturkey'] == 0 ? 'selected="selected"' : '') . ">10</option>";

    echo        "      </select></td><td rowspan='2'>ROAST TURKEY</span></td><td rowspan='2'>7.00 LB</span></td> ";

     

    The drop down shows as follows:

    0

    1

    selected="selected">2

    selected="selected">3

    selected="selected">4... etc.

     

    And the database quierie after connecting is:

     

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

     

    Record 4 has 10 as the value for the 'roastturkey'.

    I've changed it to record 5 which has a value of 5, but the dropdown does NOT change.

     

  4. So am I abandoning Pikachu??

     

    I modified:

    echo " <option value='1.00'>1  <?php echo $array['roastturkey'] == 0 ? 'selected="selected"' : ''>0</option>";

     

    To this

    echo  "<option value='1.00'  $array['roastturkey'] == 0 ? 'selected="selected"' : ''>0</option>";

     

    BUT NOT WORKING!

  5. 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.]

  6. 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.

     

     

  7. 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

  8. 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.

     

     

  9. 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.

  10. 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??

     

  11. 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.

×
×
  • 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.