Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 6 of 6
  1. #1
    Senior Member lopezvic's Avatar
    Join Date
    Jun 2004
    Location
    Miami, FL
    Posts
    100
    Member #
    6436
    how can I query it so that only the checked boxes and filled in text fields get updated. The way it is now, it inputs into the database but as soon as I update the same row again it wipes out previous submissions.

    PHP Code:
    <?php
    include "../../common.php";
    $loannum $_GET['id'];
    session_start();
    session_register("admin");


    if (isset(
    $submit))   
    {
    $query "UPDATE pipeline SET
                    status1='
    $status1',
                    status1date='
    $status1date',
                    status2='
    $status2',
                    status2date='
    $status2date',
                    status3='
    $status3',
                    status3date='
    $status3date',
                    status4='
    $status4',
                    status4date='
    $status4date',
                    status5='
    $status5',
                    status5date='
    $status5date',
                    status6='
    $status6',
                    status6date='
    $status6date',
                    status7='
    $status7',
                    status7date='
    $status7date',
                    status8='
    $status8',
                    status8date='
    $status8date',
                    status9='
    $status9',
                    status9='
    $date',
                    status10='
    $status10',
                    status10date='
    $status10date'
                    WHERE id= "
    $_POST['loannum'];
                 
                
    $result mysql_query ($query) or die(mysql_error(); // Run the query.

                
    if ($result// If it ran OK.
                
    {
                echo 
    '<h3>Thank you for Submitting to the Pipeline</h3>';
                }
            }     
                  
    ?>
    <form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">

    <table width="80%" border="1" bordercolor="#999999" align="center">
    <tr><td><div align="center"><span class="style1">Update the Pipeline</span></div></td>
    </tr>
    <tr>
    <td class="form" width="423"><b>
    <input type="checkbox" name="status1" value="1">Final 1003 Completed</b></td>

    <td class="normal" width="339"> Date:
    <input name="status1date" size="20" value="">(MM/DD/YY) </td>
    </tr>

    <tr>
    <td class="form" width="423"><b>
    <input type="checkbox" name="status2" value="1">Ordered Appraisal</b></td>
    <td class="normal" width="339"> Date:
    <input name="status2date" size="20" value=""> (MM/DD/YY) </td>
    </tr>

    <tr>
    <td class="form" width="423"><b>
    <input type="checkbox" name="status3" value="1">Ordered Title, Payoffs, CPL & Wire Instructions</b></td>
    <td class="normal" width="339"> Date:
    <input name="status3date" size="20" value=""> (MM/DD/YY) </td>
    </tr>

    <tr>
    <td class="form" width="423"><b>
    <input type="checkbox" name="status4" value="1"> Ordered Insurance</b></td>
    <td class="normal" width="339"> Date:
    <input name="status4date" size="20" value=""> (MM/DD/YY) </td>
    </tr>

    <tr>
    <td class="form" width="423"><b>
    <input type="checkbox" name="status5" value="1">Submitted to Processing</b></td>
    <td class="normal" width="339"> Date:
    <input name="status5date" size="20" value=""> (MM/DD/YY) </td>
    </tr>

    <tr>
    <td class="form" width="423"><b>
    <input type="checkbox" name="status6" value="1">Submitted to Lender</b></td>
    <td class="normal" width="339"> Date:
    <input name="status6date" size="20" value=""> (MM/DD/YY) </td>
    </tr>

    <tr>
    <td class="form" width="423"><b>
    <input type="checkbox" name="status7" value="1">Approved by Lender</b></td>
    <td class="normal" width="339"> Date:
    <input name="status7date" size="20" value=""> (MM/DD/YY) </td>
    </tr>

    <tr>
    <td class="form" width="423"><b>
    <input type="checkbox" name="status8" value="1">Conditions Met</b></td>
    <td class="normal" width="339"> Date:
    <input name="status8date" size="20" value=""> (MM/DD/YY) </td>
    </tr>

    <tr>
    <td class="form" width="423"><b>
    <input type="checkbox" name="status9" value="1">Review Final HUD</b></td>
    <td class="normal" width="339"> Date:
    <input name="status9date" size="20" value=""> (MM/DD/YY)</td>
    </tr>

    <tr>
    <td class="form" width="423"> <b>
    <input type="checkbox" name="status10" value="1">File Closed</b></td>
    <td class="normal" width="339"> Date:
    <input name="status10date" size="20" value=""> (MM/DD/YY) </td>
    </tr>
    <tr>
    <td class="form" width="423">&nbsp;</td>
    <td class="normal" width="339">&nbsp; </td>
    </tr>
    <tr>
    <td width="423" align="left" class="form"><div align="right">
    <input type="hidden" name="loannum" value="<?php echo $_GET['id']; ?>">
    <input type="submit" name="submit" value="submit" style="font-family: Verdana, Arial; font-weight:bold; font-size: 12; background-color=#EFEBE4; color=#000000; border: 1px solid #000000">
    </div></td>
    <td class="normal" width="339"><input type="submit" name="Delete" value="Delete" style="font-family: Verdana, Arial; font-weight:bold; font-size: 12; background-color=#EFEBE4; color=#000000; border: 1px solid #000000"></td>
    </tr>
    <tr>
    <td class="form">&nbsp;</td>
    <td class="normal">&nbsp;</td>
    </tr>
    </table>
    </form>

  2.  

  3. #2
    Senior Member Stylise's Avatar
    Join Date
    Jul 2005
    Location
    Mount Martha, Australia
    Posts
    229
    Member #
    10679
    Since you're updating, you should grab the "old" data to fill the form in.

    ie.

    PHP Code:
    if ($submit)
    {
        
    // update database records
    }
    else
        
    // grab data where id
        
    $query "SELECT * FROM pipeline WHERE id = '$loannum'";
                 
        
    $result mysql_query ($query) or die(mysql_error());

        if (
    mysql_num_rows($query) > 0
        
    {
            
    $pipelinedata mysql_fetch_assoc($query); 
        } 

    An example of the form...
    HTML Code:
    <form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
    
    <table width="80%" border="1" bordercolor="#999999" align="center">
    <tr><td><div align="center"><span class="style1">Update the Pipeline</span></div></td>
    </tr>
    <tr>
    <td class="form" width="423"><b>
    <input type="checkbox" name="status1" value="1">Final 1003 Completed</b></td>
    
    <td class="normal" width="339"> Date:
    <input name="status1date" size="20" value="$pipelinedata['status1date']">(MM/DD/YY) </td>
    </tr>
    ...
    Now, I haven't checked this, so if there are any errors, just yell out.

  4. #3
    Senior Member lopezvic's Avatar
    Join Date
    Jun 2004
    Location
    Miami, FL
    Posts
    100
    Member #
    6436
    Quote Originally Posted by Stylise
    Since you're updating, you should grab the "old" data to fill the form in.

    ie.

    PHP Code:
    if ($submit)
    {
        
    // update database records
    }
    else
        
    // grab data where id
        
    $query "SELECT * FROM pipeline WHERE id = '$loannum'";
                 
        
    $result mysql_query ($query) or die(mysql_error());

        if (
    mysql_num_rows($query) > 0
        
    {
            
    $pipelinedata mysql_fetch_assoc($query); 
        } 

    An example of the form...
    HTML Code:
    <form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
    
    <table width="80%" border="1" bordercolor="#999999" align="center">
    <tr><td><div align="center"><span class="style1">Update the Pipeline</span></div></td>
    </tr>
    <tr>
    <td class="form" width="423"><b>
    <input type="checkbox" name="status1" value="1">Final 1003 Completed</b></td>
    
    <td class="normal" width="339"> Date:
    <input name="status1date" size="20" value="$pipelinedata['status1date']">(MM/DD/YY) </td>
    </tr>
    ...
    Now, I haven't checked this, so if there are any errors, just yell out.

    Okay sounds good, I tried it and got a parse error unexpected '{' on this line:
    PHP Code:
    if (mysql_num_rows($query) > 0
        
    {
            
    $pipelinedata mysql_fetch_assoc($query); 
        } 
    Is there a way I can also make the checkbox checked if there is a value in the database already?

  5. #4
    Senior Member Stylise's Avatar
    Join Date
    Jul 2005
    Location
    Mount Martha, Australia
    Posts
    229
    Member #
    10679
    Sorry that should read:

    PHP Code:
    if (mysql_num_rows($query) > 0)
    {
        
    $pipelinedata mysql_fetch_assoc($query);

    (missing ')')

    I'd say the best thing you'd want to do is see if the checkbox is checked, then if it is, check if there is a value in the textbox.

    ie.

    PHP Code:
    if (isset($_POST['submit']))   
    {
        
    $errors[] = "";
        
        if (isset(
    $_POST['status1']) && empty($_POST['status1date']))
            
    $errors[] = "Please enter a date for <strong>status 1</strong>";
        if (isset(
    $_POST['status2']) && empty($_POST['status2date']))
            
    $errors[] = "Please enter a date for <strong>status 2</strong>";        
        
    // and so on...

        
        
    if (count($errors) == 0)
            echo 
    "all good"// replace this with update db code 
        
    else
            echo 
    implode($errors"<br>");
        


  6. #5
    Senior Member lopezvic's Avatar
    Join Date
    Jun 2004
    Location
    Miami, FL
    Posts
    100
    Member #
    6436
    I'm sorry for being a pain, if I put in this code you provide will it always require the checkbox to be checked and a date to be filled? The reason being is that it won't all be updated at the same time, some might be one day others a week from now.
    PHP Code:
    if (isset($_POST['submit']))   
    {
        
    $errors[] = "";
        
        if (isset(
    $_POST['status1']) && empty($_POST['status1date']))
            
    $errors[] = "Please enter a date for <strong>status 1</strong>";
        if (isset(
    $_POST['status2']) && empty($_POST['status2date']))
            
    $errors[] = "Please enter a date for <strong>status 2</strong>";        
        
    // and so on...

        
        
    if (count($errors) == 0)
            echo 
    "all good"// replace this with update db code
        
    else
            echo 
    implode($errors"<br>");
        

    If you look at the attachment I posted, it shows two rows of in the table. I need those values that have been put there to stay there and not be deleted once I update the form again. Thanks for all you help.

    Also I get this error(mysql_num_rows(): supplied argument is not a valid MySQL result ) in this part of the code:if (mysql_num_rows($query) > 0)

    Here's everything I have so far:
    PHP Code:
    if (isset($submit))   
    {
    $query "insert into pipeline SET
                    status1='
    $status1',
                    status1date='
    $status1date',
                    status2='
    $status2',
                    status2date='
    $status2date',
                    status3='
    $status3',
                    status3date='
    $status3date',
                    status4='
    $status4',
                    status4date='
    $status4date',
                    status5='
    $status5',
                    status5date='
    $status5date',
                    status6='
    $status6',
                    status6date='
    $status6date',
                    status7='
    $status7',
                    status7date='
    $status7date',
                    status8='
    $status8',
                    status8date='
    $status8date',
                    status9='
    $status9',
                    status9='
    $date',
                    status10='
    $status10',
                    status10date='
    $status10date'
                    WHERE loannum= "
    $_POST['loannum'];
                    
                
    $result mysql_query ($query) or die(mysql_error()); // Run the query.

                
    if ($result// If it ran OK.
                
    {
                echo 
    '<h3>Entry Updated Successfully</h3>';
                }
            }     
              else
        
    // grab data where id
        
    $query "SELECT status1,
                    status1date,
                    status2,
                    status2date,
                    status3,
                    status3date,
                    status4,
                    status4date,
                        status5,
                    status5date,
                    status6,
                    status6date,
                    status7,
                    status7date,
                    status8,
                    status8date,
                    status9,
                    status9date,
                    status10,status10date FROM pipeline WHERE loannum = '
    $loannum'" ;
                 
        
    $result mysql_query ($query) or die(mysql_error());

       if (
    mysql_num_rows($query) > 0)//here is where it throws and error 
    {
        
    $pipelinedata mysql_fetch_assoc($query);
    }     
    ?> 
    ANd then the form:

    HTML Code:
    <form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
    
        <table width="80%" border="1" bordercolor="#999999" align="center">
        <tr><td><div align="center"><span class="style1">Update the Pipeline</span></div></td>
        </tr>
           <tr>
             <td class="form" width="423"><b>
               <input type="checkbox" name="status1" value="1">Final 1003 Completed</b></td>
                                 
             <td class="normal" width="339"> Date:
               <input name="status1date" size="20" value="$pipelinedata['status1date']">(MM/DD/YY) </td>
          </tr>
           
           <tr>
             <td class="form" width="423"><b>                   
                <input type="checkbox" name="status2" value="1">Ordered Appraisal</b></td>
             <td class="normal" width="339"> Date:
                <input name="status2date" size="20" value="$pipelinedata['status2date']"> (MM/DD/YY) </td>   
           </tr>
    etc.....
    Attached Images Attached Images

  7. #6
    Senior Member Stylise's Avatar
    Join Date
    Jul 2005
    Location
    Mount Martha, Australia
    Posts
    229
    Member #
    10679
    That's ok.

    Basically it means, if a checkbox is checked (such as 'status1') there had to be a date entered into it's date field ('status1date'). So it doesn't check every checkbox, just those that are checked.

    Because you're loading the old data, when it updates it will just update it with the old data, so basically there won't be a change.

    I'll post it all together (I fix the mysql_num_rows bit - had the wrong variable) again.

    PHP Code:
    if (isset($_POST['submit']))   
    {
        
    $errors[] = "";
        
        if (isset(
    $_POST['status1']) && empty($_POST['status1date']))
            
    $errors[] = "Please enter a date for <strong>status 1</strong>";
        if (isset(
    $_POST['status2']) && empty($_POST['status2date']))
            
    $errors[] = "Please enter a date for <strong>status 2</strong>";        
        
    // and so on...

        
        
    if (count($errors) == 0)
        {
            
    $query "INSERT INTO pipeline SET
                        status1='
    $status1',
                        status1date='
    $status1date',
                        status2='
    $status2',
                        status2date='
    $status2date',
                        status3='
    $status3',
                        status3date='
    $status3date',
                        status4='
    $status4',
                        status4date='
    $status4date',
                        status5='
    $status5',
                        status5date='
    $status5date',
                        status6='
    $status6',
                        status6date='
    $status6date',
                        status7='
    $status7',
                        status7date='
    $status7date',
                        status8='
    $status8',
                        status8date='
    $status8date',
                        status9='
    $status9',
                        status9='
    $date',
                        status10='
    $status10',
                        status10date='
    $status10date'
                        WHERE loannum= "
    $_POST['loannum'];
                        
            
    $result mysql_query ($query) or die(mysql_error()); // Run the query.
            
            
    if ($result// If it ran OK.
                
    echo '<h3>Entry Updated Successfully</h3>';
            else
                echo 
    "Something went wrong";

        }
        else 
            echo 
    implode($errors"<br>");
    }
    else
    {
        
    // grab data where id
        
    $query "SELECT * FROM pipeline WHERE loannum = '$loannum'" ;
                 
        
    $result mysql_query ($query) or die(mysql_error());
            
        if (
    mysql_num_rows($result) > 0)//here is where it throws and error
            
    $pipelinedata mysql_fetch_assoc($query);  



Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 10:50 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com