Jump to content

phppup

Members
  • Posts

    866
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by phppup

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

     

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

     

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

     

     

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

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

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

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

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

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

  10. 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'] : '';

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