Jump to content

phppup

Members
  • Posts

    862
  • Joined

  • Last visited

  • Days Won

    1

Everything 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. Nope! It's populating the dropdown with 10 lines of: selected="selected">0 Not the value that the table has.
  5. oops! maybe not. But I think I may be able to fix it... keep you posted.
  6. EUREEEEEEKAH!!!! IT WORKED!!!! *hugs & kisses* JUMPS for JOY!!!!!
  7. 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!
  8. Pasted it in with my code from Reply #4. I have a feeling I'm duplicating ECHOs because I received error message for first line of modified code. Also, I need to ensure that unselected items maintain their default. Is there a way to incorporate that?
  9. Now I'm BEGINNING to see it! And UNDERSTAND what you mean. Is the code that Scootstah offered earlier applicable as a simpler means? Meanwhile, let me hardcode ONE selection just to see that it works.
  10. Beginning to see where this might work. But if my INITIAL default is ZERO, do i change the code to: $selected=0 Or does =1 get the code moving?
  11. 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.]
  12. Not sure WHERE TO PLACE the code now.
  13. ALSO, with the above code, how would I select MY default value, so that an item that had no selection would be recorded as the default.
  14. 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.
  15. This looks like it's establishing a PHP dropdown menu, not takiing the data from my DB, or placing it in my HTML dropdown (the same one that submitted it) from my HTML form. I can change the form to PHP, but I prefer the HTML dropdown for design purposes.
  16. 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
  17. 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.
  18. 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.
  19. THANKS.... i'll keep this open and let you know how it works out.
  20. 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??
  21. Just storing simple numbers, nothing >20 and only some are in intervals of .5 (ie: for certain items 1.0, 1.5, 2.0, 2.5 etc., and others just whole numbers: 1,2,3,4,5,etc)
  22. 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.
  23. YES, i read that. But is there a method that's considered BEST from a structure or behavioral standpoint?
×
×
  • 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.