Jump to content

phppup

Members
  • Posts

    862
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by phppup

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

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

  3. $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>";

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

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

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

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

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

     

     

     

     

     

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

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

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

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

     

     

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

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