Jump to content

phppup

Members
  • Posts

    892
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by phppup

  1. You need to READ the 3 pages prior. NOTHING is being COUNTED. There is data in a DB. I can easily view it in a browser. Now I want to have the same data populated into the numerous dropdown selections so the information resembles that which was ORIGINALLY submitted AND become the NEW DEFAULT VALUES so that THIS form can be submitted to UPDATE or CHANGE any of the data. That's the entire project.
  2. Is PHP the best way to open the new window. Zeta said she hoped this helps someone else, so here i am thinking it through. I have a PHP for putting data into a DB. The idea is that someone else will be able to access the column totals periodically. My structure is to have another form with options. Each option will run into a SELECT function that will provide information. Normally, this would be displayed on the browser, but I've found (not yet implemented) that Javascript can open a NewWindow and should be able to make the display there WITHOUT involving PHP. Am I doing something that makes sense, or sounds stupid? Feasible or futile?
  3. Correct! Although the dropdown is hardcoded as: 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>"; So when I test the script it appears to work and shows 10 as the quntity for roastturkey. Yet when I change the quiery to a differnt ID=x, the quantity of 10 remains (as if frozen). The DB has a variety of qunatities in it with varying IDs just for testing. So the script FAILS because the quantity never changes from 10. Ideas???
  4. I'm trying to retrieve data from my DB and have it populate the dropdown values inside a form: 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 I'm using this code, but cannot get the data that's inside the DB to populate the dropdown value. 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. If I use this code: $values = range(0, 10); echo "<select name=\"my_field\">\n"; foreach($values as $v) { echo "<option value=\"$v\">$v</option>\n"; }echo "</select>\n"; to generate a dropdown, it will offer options from 1 thru 10. Is there any way to make them increment by .50 (ie: 0.0, 0.5, 1.0, 1.5, 2.0, 2.5, etc.?
  6. I haven't changed the comparison value because I don't know where or how or to what... silly me :-) As a matter of fact, what I probably did throughout the process was to change it inaccuratley. So, what's my next step please?
  7. Let's try something simple: I have a form that retrieves data from database and organizes the numbers inside of a table (sometimes in an input box). Is there a simple code so that VALUES > zero will be in BOLD font?
  8. OKAY, so I managed to get a 5 in as the dropdown default for record number 4. Now I changed my quiery to record number 5, but the dropdown seems STUCK on 10. The value for record 4 for 'roastturkey' is FIVE. Any ideas???
  9. 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.
  10. 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 :-(
  11. 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.
  12. Nope! It's populating the dropdown with 10 lines of: selected="selected">0 Not the value that the table has.
  13. oops! maybe not. But I think I may be able to fix it... keep you posted.
  14. EUREEEEEEKAH!!!! IT WORKED!!!! *hugs & kisses* JUMPS for JOY!!!!!
  15. 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!
  16. 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?
  17. 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.
  18. 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?
  19. 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.]
  20. Not sure WHERE TO PLACE the code now.
  21. 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.
  22. 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.
  23. 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.
×
×
  • 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.