Jump to content

phppup

Members
  • Posts

    892
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by phppup

  1. Evidently you're assuming that I understand certain things that i do NOT know, and I'm making the same mistake with you. I am trying to save a little room in the thread, but apparently that is backfiring too. Page 1 is a dropdown that sorts the ID's to become $record_id (code on previous page) works fine. Page 2 displays the form with inputs that can be changed (also displays okay) CONNECT $record_id = (isset($_POST['record_id'])) ? $_POST['record_id'] : ''; if(!empty($record_id)) { $result = mysql_query("SELECT * FROM pass WHERE id = $record_id ") or die(mysql_error()); $row = mysql_fetch_array( $result ); echo "<FORM name='orderpage' action='myupdatepage.php' method='post'>"; 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' " . ($row['roastturkey'] == 10.00 ? 'selected="selected"' : '') . ">10</option>"; echo " </select></td><td rowspan='2'>ROAST TURKEY</span></td><td rowspan='2'>7.00 LB</span></td> "; echo " <td rowspan='2'>ujiujjpooj</span></td><td rowspan='2'> <!-- FILLER --> </span></td>"; echo " <td> <!-- BLANK CELL --> </td><td>STEAMED VEGETABLES</td><td>16.00 LB</td><td>ujiujjpooj</td>"; echo "</tr>"; echo "<tr><td> <!-- FILLER for SPAN--> </td>"; echo " <td>"; echo " <select name='broccoli'>"; echo "<option value='0.00' " . ($row['broccoli'] == 0.00 ? 'selected="selected"' : '') . ">0</option>"; echo "<option value='1.00' " . ($row['broccoli'] == 1.00 ? 'selected="selected"' : '') . ">1</option>"; echo "<option value='2.00' " . ($row['broccoli'] == 2.00 ? 'selected="selected"' : '') . ">2</option>"; echo "<option value='3.00' " . ($row['broccoli'] == 3.00 ? 'selected="selected"' : '') . ">3</option>"; echo "<option value='4.00' " . ($row['broccoli'] == 4.00 ? 'selected="selected"' : '') . ">4</option>"; echo "<option value='5.00' " . ($row['broccoli'] == 5.00 ? 'selected="selected"' : '') . ">5</option>"; echo "<option value='6.00' " . ($row['broccoli'] == 6.00 ? 'selected="selected"' : '') . ">6</option>"; echo "<option value='7.00' " . ($row['broccoli'] == 7.00 ? 'selected="selected"' : '') . ">7</option>"; echo "<option value='8.00' " . ($row['broccoli'] == 8.00 ? 'selected="selected"' : '') . ">8</option>"; echo "<option value='9.00' " . ($row['broccoli'] == 9.00 ? 'selected="selected"' : '') . ">9</option>"; echo "<option value='10.00' " . ($row['broccoli'] == 10.00 ? 'selected="selected"' : '') . ">10</option>"; echo " </select></td><td> BROCCOLI</td><td> <!-- NO PRICE HERE --> </td><td>ujiujjpooj</td>"; echo "</tr>"; echo "<tr><td>"; echo " <select name='brisket'>"; echo "<option value='0.00' " . ($row['brisket'] == 0.00 ? 'selected="selected"' : '') . ">0</option>"; echo "<option value='1.00' " . ($row['brisket'] == 1.00 ? 'selected="selected"' : '') . ">1</option>"; echo "<option value='2.00' " . ($row['brisket'] == 2.00 ? 'selected="selected"' : '') . ">2</option>"; echo "<option value='3.00' " . ($row['brisket'] == 3.00 ? 'selected="selected"' : '') . ">3</option>"; echo "<option value='4.00' " . ($row['brisket'] == 4.00 ? 'selected="selected"' : '') . ">4</option>"; echo "<option value='5.00' " . ($row['brisket'] == 5.00 ? 'selected="selected"' : '') . ">5</option>"; echo "<option value='6.00' " . ($row['brisket'] == 6.00 ? 'selected="selected"' : '') . ">6</option>"; echo "<option value='7.00' " . ($row['brisket'] == 7.00 ? 'selected="selected"' : '') . ">7</option>"; echo "<option value='8.00' " . ($row['brisket'] == 8.00 ? 'selected="selected"' : '') . ">8</option>"; echo "<option value='9.00' " . ($row['brisket'] == 9.00 ? 'selected="selected"' : '') . ">9</option>"; echo "<option value='10.00' " . ($row['brisket'] == 10.00 ? 'selected="selected"' : '') . ">10</option>"; echo " </select></td><td>BRISKET OF BEEF</td><td>32.00 LB</td><td>ujiujjpooj</td><td> <!-- FILLER --> </td>"; echo " <td>"; echo " <select name='carrots'>"; echo "<option value='0.00' " . ($row['carrots'] == 0.00 ? 'selected="selected"' : '') . ">0</option>"; echo "<option value='1.00' " . ($row['carrots'] == 1.00 ? 'selected="selected"' : '') . ">1</option>"; echo "<option value='2.00' " . ($row['carrots'] == 2.00 ? 'selected="selected"' : '') . ">2</option>"; echo "<option value='3.00' " . ($row['carrots'] == 3.00 ? 'selected="selected"' : '') . ">3</option>"; echo "<option value='4.00' " . ($row['carrots'] == 4.00 ? 'selected="selected"' : '') . ">4</option>"; echo "<option value='5.00' " . ($row['carrots'] == 5.00 ? 'selected="selected"' : '') . ">5</option>"; echo "<option value='6.00' " . ($row['carrots'] == 6.00 ? 'selected="selected"' : '') . ">6</option>"; echo "<option value='7.00' " . ($row['carrots'] == 7.00 ? 'selected="selected"' : '') . ">7</option>"; echo "<option value='8.00' " . ($row['carrots'] == 8.00 ? 'selected="selected"' : '') . ">8</option>"; echo "<option value='9.00' " . ($row['carrots'] == 9.00 ? 'selected="selected"' : '') . ">9</option>"; echo "<option value='10.00' " . ($row['carrots'] == 10.00 ? 'selected="selected"' : '') . ">10</option>"; echo " </select></td><td>CARROTS</td><td> <!-- NO PRICE HERE --> </td><td>ujiujjpooj</td>"; echo "</tr>"; <td><input type='submit' name='submitpass' value='Submit Order'> Now, if anything is to be UPDATED, the changes would have been made and when submitted to myupdatepage.php I would get a SUCCESS, not ERROR CONNECT $roastturkey = $_POST['roastturkey']; $broccoli = $_POST['broccoli']; $brisket = $_POST['brisket']; $carrots = $_POST['carrots']; $mytabletest = array();foreach($_POST as $indexName => $value) { $mytabletest[] = "$indexName = \"$value\"";} $fields = implode(",", $mytabletest); $sql=("UPDATE mytabletest SET $fields WHERE id = $record_id "); if($result){ echo "Successful"; } else { echo "ERROR"; } I need to know what to add, and WHERE to place it.
  2. I'm unable to get from page 2 to page 3 with a SUCCESSful UPDATING of the DB
  3. ALL the code is posted at bottom of this page 2
  4. the first page has this code to display the fields: connect: $result = mysql_query("SELECT * FROM pass WHERE id = $record_id ") or die(mysql_error()); $row = mysql_fetch_array( $result ); echo echo echo submit button the second file that gets called AFTER submission of UPDATES is: if(isset($_POST['action']) && $_POST['action'] == 'submitform') { $roastturkey = $_POST['roastturkey']; $broccoli = $_POST['broccoli']; $brisket = $_POST['brisket']; $carrots = $_POST['carrots']; } $pass = array();foreach($_POST as $indexName => $value) { $pass[] = "$indexName = \"$value\"";} $fields = implode(",", $pass); $sql=("UPDATE pass SET $fields WHERE id = $record_id $result=mysql_query($sql); "); if($result){ echo "Successful"; else { echo "ERROR"; } so where exactly shall i put new code??
  5. Good morning everyone! OKAY, let's sort of forget the aforementioned pages for a minute, because they seem to be working (kind of). Here's the issue: My form is created by this code if(mysql_num_rows($query) > 0){ while($row = mysql_fetch_assoc($query)) { $record_id = $row['ID']; echo '<option value="' . $record_id . '">' . $record_id . '</option>'; }} which gives me a dropdown of ALL my id's by row, and renames them $record_id This takes me to a page that carries that record_id and displays a form with values as inputs that can be changed. If there are UPDATES made, then hitting the submit button goes to another php script (shown previously) that should make the update and offer a Success message." My problem here is that updates are NOT occurring, and I am recieving a scripted ERROR message. Apparently my $record_id is NOT being forwarded beyond the first instance. How do I bring it to this second file? Should I be using SESSION, or is a hidden file in order? And where shall it be placed?
  6. I originally had a if(isset($_POST['action']) && $_POST['action'] == 'submitform') { itemized items } but took it out while trying to de-bug this scripting
  7. nO, NO , NO. I'm saying that a book said to have that post info on top of page.
  8. The PHP book said to put it there, so I put it there. Meanwhile, I need to get the UPDATES into the correct record ID using the form. Ideas?
  9. OKAY, I pulled out the conditional and it printed: Array ( [roastturkey] => 2.00 [broccoli] => 0.00 [brisket] => 6.00 [carrots] => 0.00 [submitpass] => Submit Order ) 1 so now the question is, How will it know which row ID to post the new data to?
  10. Notice: Undefined variable: result in... line 91 This correcsponds to my: if($result){ towards the end.
  11. AFTER CONNECTION: //save the data on the DB and send the email if(isset($_POST['action']) && $_POST['action'] == 'submitform') { //recieve the variables $roastturkey = $_POST['roastturkey']; $broccoli = $_POST['broccoli']; $brisket = $_POST['brisket']; $carrots = $_POST['carrots']; } $record_id = (isset($_POST['record_id'])) ? $_POST['record_id'] : '';//check for $record_id emptiness if(!empty($record_id)){ echo "<pre>", print_r($_POST), "</pre>"; $testtable = array();foreach($_POST as $indexName => $value) { $testtable[] = "$indexName = \"$value\"";} $fields = implode(",", $testtable); $sql=("UPDATE testtable SET $fields WHERE id = $record_id "); echo "<pre>", print_r($_POST), "</pre"; echo "$sql"; $result=mysql_query($sql); } if($result){ echo "Successful"; } else { echo "ERROR"; }
  12. Not sure if I was posting it correctly, so i stuck it in 3 different places, and NO MESSAGES
  13. No messages. Just the same ERROR message from my own script. So is it not grabbing the fields, or is it not grabbing the record_id number?
  14. if(isset($_POST['action']) && $_POST['action'] == 'submitform') { //recieve the variables $roastturkey = $_POST['roastturkey']; $broccoli = $_POST['broccoli']; $brisket = $_POST['brisket']; $carrots = $_POST['carrots']; $record_id = (isset($_POST['record_id'])) ? $_POST['record_id'] : ''; if(!empty($record_id)){ $testtable = array();foreach($_POST as $indexName => $value) { $myUpdateList[] = "$indexName = \"$value\"";} $fields = implode(",", $testtable); $sql=("UPDATE testtable SET $fields WHERE id = $record_id "); $result=mysql_query($sql); } if($result){ echo "Successful"; } else { echo "ERROR"; } EDITed for CODE tags.
  15. Got rid of the T-string error. There are no MySQL errors, but the page takes me to MY own ERROR message rather than SUCCESS after submission. SO it's missing something. I changed the table name to MY testtable name. Are all others AS IS?
  16. well, I'm glad you're here, because I'm doing something wrong. I posted it as written: $testtable = array();foreach($_POST as $indexName => $value) { $myUpdateList[] = "$indexName = \"$value\"";} $fields = implode(",", $testtable); $sql=("UPDATE testtable SET $fields WHERE id = $record_id "); but I was getting a T-string error
  17. I need to update fields through a form, but there are MANY fields. Instead of UPDATE table SET email='$email', name, etc, for EVERY value, is there a shortcut that might loop through all my fields, since I want every one of them to be checked for updated info.
  18. Having trouble using the code mentioned. Is it a syntax error? Should MyUpdateList be my database name? I'm sure it's a minor glitch. Or maybe I'm better of listing each item, as the shortcut is requiring much more work.. LOL
  19. After submission I want to be able to pull up a customer record and the LAST 4 DIGITS of the social security number that was provided. What's the best way to do this? Am I best off having them INPUT the digits into three different fields that will load into the DB as Socxxx, Socxx, and Socxxxx, and just calling the Socxxxx field, or is there a way to 'strip' all but the last 4 digits?
  20. No numbers, no characters, just a capitall lettter and the remaining lowercase letters. Also, if I want toeveviate some of the PHP burden and add this in Javascript, should it go directly ahead of the PHP, or be intertwined with it?
  21. So how would I ensure that a name field is SAVED with the first letter capitalized, and the rest all lowercase, regardless of how it was typed into the field?
  22. I might want it capitalised so that when I send an email, it can be addressed "Dear Greenballoon" as opposed to greenballon. So, is there a way to do it, or it it best left until I send the email.
  23. While we're on the subject, is there a way to ensure that the first letter of a name is captalized, and the rest lowercase? Or is this best handled later on, when the name is being used and called from the DB. PS: some of us comment are code as to WHAT we are doing because we're just not that good yet, and we need to explain it to ourselves.
  24. Each row contains quantities from a form. I then ECHO the form after submission and ECHO the values. I would like all values >0 to be BOLD. while($result=mysql_fetch_array($query)) {$value=result["somerow"]; if ($value>o) { echo "Some field name <input name='data' type='text' id='bold' value='$value' /><br/>"; } else{ echo "Some field name <input name='data' type='text' value='$value' /><br/>"; }} the above codeseems promising, but I'm not sure how to LOOP it so it evaluates ALL the values in their fields, or if there might be a better method.
  25. Code not working Getting T-string error: $myUpdateList = array();foreach($_POST as $indexName => $value) { $myUpdateList[] = "$indexName = \"$value\"";} $fields = implode(",", $myUpdateList); $sql=UPDATE pass SET $fields WHERE id = 3; Am I missing parenthesis or semi colons, or quotes?
×
×
  • 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.