Jump to content

phppup

Members
  • Posts

    892
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by phppup

  1. Yes, the dropdowns were ALL written manually with HTMN (i've since learned there is a php method that's less exhausting). The id is being input into a field calling it from the DB as record_id. $record_id = (isset($_POST['record_id'])) ? $_POST['record_id'] : '';
  2. I appreciate the humor. It's just that as a newbie, ya never know if htere's some variable at work that you haven't encountered yet. I was thinking they might have a similar numeric value or name concontination or some sort. PS: the broccoli is STEAMED.... so at worst it gets soggy. LOL
  3. Using 85% dropdowns, and then some standard name,address input fields. Ummmm, easiest way to provide the $id for the script?
  4. And why is my BROCCOLI now BURNT.... i suppose this is more than just you being funny. And will I ever actually see (or need to use) my BURNT items?
  5. I'm just doing what the internet tell me (which is probably why I'm having so much trouble, huh). So instead of listing them twice, what??
  6. Here is the code that was at the top of my INSERT.php code $roastturkey = $_POST['roastturkey']; $broccoli = $_POST['broccoli']; $brisket = $_POST['brisket']; $carrots = $_POST['carrots']; and then it repeats as the VALUES to be posted. I'm still a bit confused about my UPDATE statement. UPDATe mytable SET (all the post names) WHERE id="id" ...... so the SET is the list of fields, but there's a way to loop through them to avoid listing each one seperately?? Please help. As I've discovered I could have saved LOTS of time had I understood and implemented other PHP shortcuts earlier in this process. Thanks.
  7. Don't have the code yet. I have multiple fields form a form that were input from dropdown menus. So I would need a loop for each item in row??
  8. SO if I have 50 fields in a single row, I need to list them in the same manner as when I input them from the form? There is now way to simply state that I want the entire ID row to be overwritten (since MySQL will automatically NOT overwrite items that were not changed)?
  9. do I need to list every field by name individually, or is there a way to UPDATE the entire row by ID?
  10. I want to UPDATE reords in my DB using a form. What is the correct UPDATE syntax. All the tutorials seem to offer lessons on updating full columns or ages, but not a single record row by ID.
  11. Thanks again to everyone. I'm gonna mark this one resolved!
  12. OK. So now all I need to do is build this page into a form, and have the 'action' point to a PHP page that connects and the run UPDATE * FROM mytable WHERE id = 'this-record' Uh oh, is this a new thread... LOL
  13. ie: $meat.... yes, i played with that early on in my PHP endeavors. everything was so structured, and then I scratched my head and started naming items with names like sasperilla and heebeeegeeebeees. It was confusinig, but it DID work... LOL So in actuality, DB fatigue not withstanding, fetch_array is just a bit more generic, and kinda ensures that it'll locate what the fuction is looking for by casting a wider net, so to speak.
  14. So, $row = mysql_fetch_array is forcing the DB to do more work than it needs to by scanning the entire DB? And fetch_row directs it more definitively??
  15. I GOT IT!!!!! Noticed that i missed the array in option 10, called it $row, and SUCCESS! Thank you EVERYONE for persevering. If there are any tweaks to my code, please let me know. And if someone can let me know whether I would be BETTER off using arrays, please guide me to the difference of $row versus $array. Thanks sooo much again!
  16. Note: had EVERYTHING as ARRAY... just switched them to $row on a hunch that didn't work. I'll put them back to $array
  17. $result = mysql_query("SELECT * FROM pass WHERE id = '4' ") or die(mysql_error()); $row = mysql_fetch_array( $result ); echo "There are " . $row['roastturkey'] ." servings"; // this verifies that i CAN get the data echo "<table border='1'>"; echo "<tr> <th>Name</th> <th>Comment</th> <th>Email Address</th></tr>"; //took from another table just to get headings and columns echo "<tr><td>"; echo "<select name='roastturkey'>"; echo "<option value='0.00' " . ($row['roastturkey'] == 0.00 ? 'selected="selected"' : '') . ">0</option>"; echo "<option value='1.00' " . ($row['roastturkey'] == 1.00 ? 'selected="selected"' : '') . ">1</option>"; echo "<option value='2.00' " . ($row['roastturkey'] == 2.00 ? 'selected="selected"' : '') . ">2</option>"; echo "<option value='3.00' " . ($row['roastturkey'] == 3.00 ? 'selected="selected"' : '') . ">3</option>"; echo "<option value='4.00' " . ($row['roastturkey'] == 4.00 ? 'selected="selected"' : '') . ">4</option>"; echo "<option value='5.00' " . ($row['roastturkey'] == 5.00 ? 'selected="selected"' : '') . ">5</option>"; echo "<option value='6.00' " . ($row['roastturkey'] == 6.00 ? 'selected="selected"' : '') . ">6</option>"; echo "<option value='7.00' " . ($row['roastturkey'] == 7.00 ? 'selected="selected"' : '') . ">7</option>"; echo "<option value='8.00' " . ($row['roastturkey'] == 8.00 ? 'selected="selected"' : '') . ">8</option>"; echo "<option value='9.00' " . ($row['roastturkey'] == 9.00 ? 'selected="selected"' : '') . ">9</option>"; echo "<option value='10.00' " . ($array['roastturkey'] == 10.00 ? 'selected="selected"' : '') . ">10</option>";
  18. $result = mysql_query("SELECT * FROM mytest WHERE id = '4' ") and I change the ID accordingly, hoping for a different and accurate result, which hasn't happened. Note: everything is connecting etc, as I have an alternate page WITHOUT the dropdown scenario and it runs fine, echoing all accurate data. I thought this would be an easy way to update info, can you think of a better method in case this issue is unresolveable. Although I don't think I'm the first to attempt this method.
  19. In my table I'm using $row. Not too familiar with arrays (which is also why I hardcoded initially, as I didn't know that there was a simpler way with PHP)
  20. The statement you provided does nothing. But when I use echo "There are " . $row['roastturkey'] ." servings"; inside my table, it provides the correct values (even when the ID is changed)
  21. Took out the single quote: echo "<option value='0.00' " . ($array['roastturkey'] == 0.00 ? 'selected="selected"' : '') . ">0</option>"; echo "<option value='1.00' " . ($array['roastturkey'] == 1.00 ? 'selected="selected"' : '') . ">1</option>"; echo "<option value='2.00' " . ($array['roastturkey'] == 2.00 ? 'selected="selected"' : '') . ">2</option>"; echo "<option value='3.00' " . ($array['roastturkey'] == 3.00 ? 'selected="selected"' : '') . ">3</option>"; echo "<option value='4.00' " . ($array['roastturkey'] == 4.00 ? 'selected="selected"' : '') . ">4</option>"; echo "<option value='5.00' " . ($array['roastturkey'] == 5.00 ? 'selected="selected"' : '') . ">5</option>"; echo "<option value='6.00' " . ($array['roastturkey'] == 6.00 ? 'selected="selected"' : '') . ">6</option>"; echo "<option value='7.00' " . ($array['roastturkey'] == 7.00 ? 'selected="selected"' : '') . ">7</option>"; echo "<option value='8.00' " . ($array['roastturkey'] == 8.00 ? 'selected="selected"' : '') . ">8</option>"; echo "<option value='9.00' " . ($array['roastturkey'] == 9.00 ? 'selected="selected"' : '') . ">9</option>"; echo "<option value='10.00' " . ($array['roastturkey'] == 10.00 ? 'selected="selected"' : '') . ">10</option>"; result in dropdown still at zero :-( What else would you test. AT this point, I'll give you the whole damn thing.. LOL
  22. I see what you mean. Made the change, but still no difference. The DB field is VARCHAR and displays x.xx for value. When I changed back to ZERO as the comparison, my result shifts to 10. Don't know why.
  23. I've changed it from: 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>"; to echo "<option value='0.00' " . ($array['roastturkey'] == '0' ? 'selected="selected"' : '') . ">0</option>"; echo "<option value='1.00' " . ($array['roastturkey'] == '1' ? 'selected="selected"' : '') . ">1</option>"; echo "<option value='2.00' " . ($array['roastturkey'] == '2' ? 'selected="selected"' : '') . ">2</option>"; echo "<option value='3.00' " . ($array['roastturkey'] == '3' ? 'selected="selected"' : '') . ">3</option>"; echo "<option value='4.00' " . ($array['roastturkey'] == '4' ? 'selected="selected"' : '') . ">4</option>"; echo "<option value='5.00' " . ($array['roastturkey'] == '5' ? 'selected="selected"' : '') . ">5</option>"; echo "<option value='6.00' " . ($array['roastturkey'] == '6' ? 'selected="selected"' : '') . ">6</option>"; echo "<option value='7.00' " . ($array['roastturkey'] == '7' ? 'selected="selected"' : '') . ">7</option>"; echo "<option value='8.00' " . ($array['roastturkey'] == '8' ? 'selected="selected"' : '') . ">8</option>"; echo "<option value='9.00' " . ($array['roastturkey'] == '9' ? 'selected="selected"' : '') . ">9</option>"; echo "<option value='10.00' " . ($array['roastturkey'] == '10' ? 'selected="selected"' : '') . ">10</option>"; and now I get ZERO for all the ID's that I query. The INITIAL default value is ZERO. Then the value changes when the data is submitted though the form initially and posted into the DB. Does the value that is input need to be coompared. Does the hardcoding need to be altered for every instance AFFTER the data is recorded?
  24. The items in the form are each genreated by a line like this: echo "".$row['ITEM1'].""; There many items. Some are zero, some are greater. Is there a tool (like *) that I can use with a > function for the entire form, or do i need to apply the form for every item individually?
  25. FULL STORY REPEATED: A form inputs data into several fields named turkey, roastbeef, spinach, potatoes, etc (i'll stop bc it's lunchtime now... LOL). Input process is FINE. Now DB has several entries with varying quantiities in each. Record A has 5 (orders) of turkey and 2 spinach Record B has 3 (orders) of roast beef and 1 spinach, and 2 potaoes, etc. Any item NOT ordered has a DEFAULT of ZERO. I can successfully view all orders in a browser... NO PROBLEM. Now I have a SECOND form (identical to the first) and I want to ECHO the values into it. I want those values to appear INSIDE the dropdown with 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 so that if customer A decides that 5 orders of turkey is too much, then the order can be UPDATED to the DB with the NEW VALUE. 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. My SECOND form has 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 I am currently using the statement: $result = mysql_query("SELECT * FROM mytablename WHERE id = '5' ") just to get a value for testing purposes. Then I change the ID within the statement to check the functionality. At first, there was NO SUCCESS. Yesterday, I got the dropdown's value to change to 10 (which was valid). But NOW the dropdown has 'adopted' 10 as the default, as it does NOT CHANGE when I alter the ID value to orders that contain a value that is NOT 10 in them. Any solutions?
×
×
  • 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.