PHP - While editing form field using 'select' default value or previous value getting deleted












0















        <td>Three And Half Yearly</td>
<td><input type="date" class="form-control" name="Three_and_Half_Yearly" value="<?php echo $Three_and_Half_Yearly; ?>"></td>
<td><select class="form-control" name="Three_And_Half_Yearly_DO_NO"> <option value=""></option>
<option value="Upcoming">Upcoming</option>
<option value="Completed">Completed</option>
<option value="On_going">On going</option>
<option value="Postponed">Postponed</option>
<option value="Canceled">Canceled</option>
<option value="<?php echo $Three_And_Half_Yearly_DO_NO; ?>" selected disabled hidden><?php echo $Three_And_Half_Yearly_DO_NO; ?></option>
</select></td>
</tr>
<tr>
<td>Four Yearly</td>
<td><input type="date" class="form-control" name="Four_Yearly" value="<?php echo $Four_Yearly; ?>"></td>
<td><select class="form-control" name="Four_Yearly_DO_NO"> <option value=""></option>
<option value="Upcoming">Upcoming</option>
<option value="Completed">Completed</option>
<option value="On_going">On going</option>
<option value="Postponed">Postponed</option>
<option value="Canceled">Canceled</option>
<option value="<?php echo $Four_Yearly_DO_NO; ?>" selected disabled hidden><?php echo $Four_Yearly_DO_NO; ?></option>
</select></td>


Above is part of my form field, whenever i run my PHP update query, the default or previous values getting replaced with null values. please help me to keep the old values and edit the other 'select drop-down' values.



My php update query is,



$query = mysql_query("UPDATE Inspection_schedule SET 
Client_Contract_Number = '$Client_Contract_Number',
Currently_Using = '$Currently_Using',
MBPS_EAM_Number_RIGT ='$MBPS_EAM_Number_RIGT',
Model_and_Type = '$Model_and_Type',
LFour_Yearly = '$LFour_Yearly',
LFour_Yearly_DO_NO = '$LFour_Yearly_DO_NO',
Six_Monthly = '$Six_Monthly',
Six_Monthly_DO_NO = '$Six_Monthly_DO_NO',
One_Yearly ='$One_Yearly',
One_Yearly_DO_NO = '$One_Yearly_DO_NO',
One_and_Half_Yearly = '$One_and_Half_Yearly',
One_And_Half_Yearly_DO_NO = '$One_And_Half_Yearly_DO_NO',
Two_Yearly ='$Two_Yearly',
Two_Yearly_DO_NO = '$Two_Yearly_DO_NO',
Two_and_Half_Yearly = '$Two_and_Half_Yearly',
Two_And_Half_Yearly_DO_NO = '$Two_And_Half_Yearly_DO_NO',
Three_Yearly = '$Three_Yearly',
Three_Yearly_DO_NO = '$Three_Yearly_DO_NO',
Three_and_Half_Yearly = '$Three_and_Half_Yearly',
Three_And_Half_Yearly_DO_NO= '$Three_And_Half_Yearly_DO_NO',
Four_Yearly='$Four_Yearly',
Four_Yearly_DO_NO = '$Four_Yearly_DO_NO',
Remarks = '$Remarks' WHERE ID=$Id");









share|improve this question

























  • Can you include your "PHP update query" as well, please?

    – man0v
    Nov 26 '18 at 12:09











  • I have tried this way also... but found no luck <option value="" selected disabled hidden><?php echo $Two_And_Half_Yearly_DO_NO; ?></option>

    – Siji
    Nov 26 '18 at 12:10











  • No, what I mean is can you put you "PHP update query" in the question so I can see it....

    – man0v
    Nov 26 '18 at 12:11











  • @man0v my update query is added

    – Siji
    Nov 26 '18 at 12:15











  • Can you put any other relevant code, please? You must have code that is setting up the variables $Four_Yearly_DO_NO and $Three_And_Half_Yearly_DO_NO

    – man0v
    Nov 26 '18 at 12:48
















0















        <td>Three And Half Yearly</td>
<td><input type="date" class="form-control" name="Three_and_Half_Yearly" value="<?php echo $Three_and_Half_Yearly; ?>"></td>
<td><select class="form-control" name="Three_And_Half_Yearly_DO_NO"> <option value=""></option>
<option value="Upcoming">Upcoming</option>
<option value="Completed">Completed</option>
<option value="On_going">On going</option>
<option value="Postponed">Postponed</option>
<option value="Canceled">Canceled</option>
<option value="<?php echo $Three_And_Half_Yearly_DO_NO; ?>" selected disabled hidden><?php echo $Three_And_Half_Yearly_DO_NO; ?></option>
</select></td>
</tr>
<tr>
<td>Four Yearly</td>
<td><input type="date" class="form-control" name="Four_Yearly" value="<?php echo $Four_Yearly; ?>"></td>
<td><select class="form-control" name="Four_Yearly_DO_NO"> <option value=""></option>
<option value="Upcoming">Upcoming</option>
<option value="Completed">Completed</option>
<option value="On_going">On going</option>
<option value="Postponed">Postponed</option>
<option value="Canceled">Canceled</option>
<option value="<?php echo $Four_Yearly_DO_NO; ?>" selected disabled hidden><?php echo $Four_Yearly_DO_NO; ?></option>
</select></td>


Above is part of my form field, whenever i run my PHP update query, the default or previous values getting replaced with null values. please help me to keep the old values and edit the other 'select drop-down' values.



My php update query is,



$query = mysql_query("UPDATE Inspection_schedule SET 
Client_Contract_Number = '$Client_Contract_Number',
Currently_Using = '$Currently_Using',
MBPS_EAM_Number_RIGT ='$MBPS_EAM_Number_RIGT',
Model_and_Type = '$Model_and_Type',
LFour_Yearly = '$LFour_Yearly',
LFour_Yearly_DO_NO = '$LFour_Yearly_DO_NO',
Six_Monthly = '$Six_Monthly',
Six_Monthly_DO_NO = '$Six_Monthly_DO_NO',
One_Yearly ='$One_Yearly',
One_Yearly_DO_NO = '$One_Yearly_DO_NO',
One_and_Half_Yearly = '$One_and_Half_Yearly',
One_And_Half_Yearly_DO_NO = '$One_And_Half_Yearly_DO_NO',
Two_Yearly ='$Two_Yearly',
Two_Yearly_DO_NO = '$Two_Yearly_DO_NO',
Two_and_Half_Yearly = '$Two_and_Half_Yearly',
Two_And_Half_Yearly_DO_NO = '$Two_And_Half_Yearly_DO_NO',
Three_Yearly = '$Three_Yearly',
Three_Yearly_DO_NO = '$Three_Yearly_DO_NO',
Three_and_Half_Yearly = '$Three_and_Half_Yearly',
Three_And_Half_Yearly_DO_NO= '$Three_And_Half_Yearly_DO_NO',
Four_Yearly='$Four_Yearly',
Four_Yearly_DO_NO = '$Four_Yearly_DO_NO',
Remarks = '$Remarks' WHERE ID=$Id");









share|improve this question

























  • Can you include your "PHP update query" as well, please?

    – man0v
    Nov 26 '18 at 12:09











  • I have tried this way also... but found no luck <option value="" selected disabled hidden><?php echo $Two_And_Half_Yearly_DO_NO; ?></option>

    – Siji
    Nov 26 '18 at 12:10











  • No, what I mean is can you put you "PHP update query" in the question so I can see it....

    – man0v
    Nov 26 '18 at 12:11











  • @man0v my update query is added

    – Siji
    Nov 26 '18 at 12:15











  • Can you put any other relevant code, please? You must have code that is setting up the variables $Four_Yearly_DO_NO and $Three_And_Half_Yearly_DO_NO

    – man0v
    Nov 26 '18 at 12:48














0












0








0








        <td>Three And Half Yearly</td>
<td><input type="date" class="form-control" name="Three_and_Half_Yearly" value="<?php echo $Three_and_Half_Yearly; ?>"></td>
<td><select class="form-control" name="Three_And_Half_Yearly_DO_NO"> <option value=""></option>
<option value="Upcoming">Upcoming</option>
<option value="Completed">Completed</option>
<option value="On_going">On going</option>
<option value="Postponed">Postponed</option>
<option value="Canceled">Canceled</option>
<option value="<?php echo $Three_And_Half_Yearly_DO_NO; ?>" selected disabled hidden><?php echo $Three_And_Half_Yearly_DO_NO; ?></option>
</select></td>
</tr>
<tr>
<td>Four Yearly</td>
<td><input type="date" class="form-control" name="Four_Yearly" value="<?php echo $Four_Yearly; ?>"></td>
<td><select class="form-control" name="Four_Yearly_DO_NO"> <option value=""></option>
<option value="Upcoming">Upcoming</option>
<option value="Completed">Completed</option>
<option value="On_going">On going</option>
<option value="Postponed">Postponed</option>
<option value="Canceled">Canceled</option>
<option value="<?php echo $Four_Yearly_DO_NO; ?>" selected disabled hidden><?php echo $Four_Yearly_DO_NO; ?></option>
</select></td>


Above is part of my form field, whenever i run my PHP update query, the default or previous values getting replaced with null values. please help me to keep the old values and edit the other 'select drop-down' values.



My php update query is,



$query = mysql_query("UPDATE Inspection_schedule SET 
Client_Contract_Number = '$Client_Contract_Number',
Currently_Using = '$Currently_Using',
MBPS_EAM_Number_RIGT ='$MBPS_EAM_Number_RIGT',
Model_and_Type = '$Model_and_Type',
LFour_Yearly = '$LFour_Yearly',
LFour_Yearly_DO_NO = '$LFour_Yearly_DO_NO',
Six_Monthly = '$Six_Monthly',
Six_Monthly_DO_NO = '$Six_Monthly_DO_NO',
One_Yearly ='$One_Yearly',
One_Yearly_DO_NO = '$One_Yearly_DO_NO',
One_and_Half_Yearly = '$One_and_Half_Yearly',
One_And_Half_Yearly_DO_NO = '$One_And_Half_Yearly_DO_NO',
Two_Yearly ='$Two_Yearly',
Two_Yearly_DO_NO = '$Two_Yearly_DO_NO',
Two_and_Half_Yearly = '$Two_and_Half_Yearly',
Two_And_Half_Yearly_DO_NO = '$Two_And_Half_Yearly_DO_NO',
Three_Yearly = '$Three_Yearly',
Three_Yearly_DO_NO = '$Three_Yearly_DO_NO',
Three_and_Half_Yearly = '$Three_and_Half_Yearly',
Three_And_Half_Yearly_DO_NO= '$Three_And_Half_Yearly_DO_NO',
Four_Yearly='$Four_Yearly',
Four_Yearly_DO_NO = '$Four_Yearly_DO_NO',
Remarks = '$Remarks' WHERE ID=$Id");









share|improve this question
















        <td>Three And Half Yearly</td>
<td><input type="date" class="form-control" name="Three_and_Half_Yearly" value="<?php echo $Three_and_Half_Yearly; ?>"></td>
<td><select class="form-control" name="Three_And_Half_Yearly_DO_NO"> <option value=""></option>
<option value="Upcoming">Upcoming</option>
<option value="Completed">Completed</option>
<option value="On_going">On going</option>
<option value="Postponed">Postponed</option>
<option value="Canceled">Canceled</option>
<option value="<?php echo $Three_And_Half_Yearly_DO_NO; ?>" selected disabled hidden><?php echo $Three_And_Half_Yearly_DO_NO; ?></option>
</select></td>
</tr>
<tr>
<td>Four Yearly</td>
<td><input type="date" class="form-control" name="Four_Yearly" value="<?php echo $Four_Yearly; ?>"></td>
<td><select class="form-control" name="Four_Yearly_DO_NO"> <option value=""></option>
<option value="Upcoming">Upcoming</option>
<option value="Completed">Completed</option>
<option value="On_going">On going</option>
<option value="Postponed">Postponed</option>
<option value="Canceled">Canceled</option>
<option value="<?php echo $Four_Yearly_DO_NO; ?>" selected disabled hidden><?php echo $Four_Yearly_DO_NO; ?></option>
</select></td>


Above is part of my form field, whenever i run my PHP update query, the default or previous values getting replaced with null values. please help me to keep the old values and edit the other 'select drop-down' values.



My php update query is,



$query = mysql_query("UPDATE Inspection_schedule SET 
Client_Contract_Number = '$Client_Contract_Number',
Currently_Using = '$Currently_Using',
MBPS_EAM_Number_RIGT ='$MBPS_EAM_Number_RIGT',
Model_and_Type = '$Model_and_Type',
LFour_Yearly = '$LFour_Yearly',
LFour_Yearly_DO_NO = '$LFour_Yearly_DO_NO',
Six_Monthly = '$Six_Monthly',
Six_Monthly_DO_NO = '$Six_Monthly_DO_NO',
One_Yearly ='$One_Yearly',
One_Yearly_DO_NO = '$One_Yearly_DO_NO',
One_and_Half_Yearly = '$One_and_Half_Yearly',
One_And_Half_Yearly_DO_NO = '$One_And_Half_Yearly_DO_NO',
Two_Yearly ='$Two_Yearly',
Two_Yearly_DO_NO = '$Two_Yearly_DO_NO',
Two_and_Half_Yearly = '$Two_and_Half_Yearly',
Two_And_Half_Yearly_DO_NO = '$Two_And_Half_Yearly_DO_NO',
Three_Yearly = '$Three_Yearly',
Three_Yearly_DO_NO = '$Three_Yearly_DO_NO',
Three_and_Half_Yearly = '$Three_and_Half_Yearly',
Three_And_Half_Yearly_DO_NO= '$Three_And_Half_Yearly_DO_NO',
Four_Yearly='$Four_Yearly',
Four_Yearly_DO_NO = '$Four_Yearly_DO_NO',
Remarks = '$Remarks' WHERE ID=$Id");






php drop-down-menu






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 26 '18 at 12:13







Siji

















asked Nov 26 '18 at 12:06









SijiSiji

136




136













  • Can you include your "PHP update query" as well, please?

    – man0v
    Nov 26 '18 at 12:09











  • I have tried this way also... but found no luck <option value="" selected disabled hidden><?php echo $Two_And_Half_Yearly_DO_NO; ?></option>

    – Siji
    Nov 26 '18 at 12:10











  • No, what I mean is can you put you "PHP update query" in the question so I can see it....

    – man0v
    Nov 26 '18 at 12:11











  • @man0v my update query is added

    – Siji
    Nov 26 '18 at 12:15











  • Can you put any other relevant code, please? You must have code that is setting up the variables $Four_Yearly_DO_NO and $Three_And_Half_Yearly_DO_NO

    – man0v
    Nov 26 '18 at 12:48



















  • Can you include your "PHP update query" as well, please?

    – man0v
    Nov 26 '18 at 12:09











  • I have tried this way also... but found no luck <option value="" selected disabled hidden><?php echo $Two_And_Half_Yearly_DO_NO; ?></option>

    – Siji
    Nov 26 '18 at 12:10











  • No, what I mean is can you put you "PHP update query" in the question so I can see it....

    – man0v
    Nov 26 '18 at 12:11











  • @man0v my update query is added

    – Siji
    Nov 26 '18 at 12:15











  • Can you put any other relevant code, please? You must have code that is setting up the variables $Four_Yearly_DO_NO and $Three_And_Half_Yearly_DO_NO

    – man0v
    Nov 26 '18 at 12:48

















Can you include your "PHP update query" as well, please?

– man0v
Nov 26 '18 at 12:09





Can you include your "PHP update query" as well, please?

– man0v
Nov 26 '18 at 12:09













I have tried this way also... but found no luck <option value="" selected disabled hidden><?php echo $Two_And_Half_Yearly_DO_NO; ?></option>

– Siji
Nov 26 '18 at 12:10





I have tried this way also... but found no luck <option value="" selected disabled hidden><?php echo $Two_And_Half_Yearly_DO_NO; ?></option>

– Siji
Nov 26 '18 at 12:10













No, what I mean is can you put you "PHP update query" in the question so I can see it....

– man0v
Nov 26 '18 at 12:11





No, what I mean is can you put you "PHP update query" in the question so I can see it....

– man0v
Nov 26 '18 at 12:11













@man0v my update query is added

– Siji
Nov 26 '18 at 12:15





@man0v my update query is added

– Siji
Nov 26 '18 at 12:15













Can you put any other relevant code, please? You must have code that is setting up the variables $Four_Yearly_DO_NO and $Three_And_Half_Yearly_DO_NO

– man0v
Nov 26 '18 at 12:48





Can you put any other relevant code, please? You must have code that is setting up the variables $Four_Yearly_DO_NO and $Three_And_Half_Yearly_DO_NO

– man0v
Nov 26 '18 at 12:48












1 Answer
1






active

oldest

votes


















0














    I have made the droop down list dynamic and solved the issue...    
<td><input type="date" class="form-control" name="LFour_Yearly" value="<?php echo $LFour_Yearly; ?>"></td>
<td><select class="form-control" name="LFour_Yearly_DO_NO"> <option value=""></option>
<?php
$statusquery=mysql_query("SELECT * FROM inspection_status");
$statusrowcount=mysql_num_rows($statusquery);

for($i=1;$i<=$statusrowcount;$i++)
{
$statusrow=mysql_fetch_array($statusquery);
?>
<option value="<?php echo $statusrow["status"] ?>"
<?php
if ($row['LFour_Yearly_DO_NO']==$statusrow["status"])
{
echo "selected";
}
?>
><?php echo $statusrow["status"] ?><?php}?></select> </td>
</tr>





share|improve this answer


























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53480761%2fphp-while-editing-form-field-using-select-default-value-or-previous-value-ge%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














        I have made the droop down list dynamic and solved the issue...    
    <td><input type="date" class="form-control" name="LFour_Yearly" value="<?php echo $LFour_Yearly; ?>"></td>
    <td><select class="form-control" name="LFour_Yearly_DO_NO"> <option value=""></option>
    <?php
    $statusquery=mysql_query("SELECT * FROM inspection_status");
    $statusrowcount=mysql_num_rows($statusquery);

    for($i=1;$i<=$statusrowcount;$i++)
    {
    $statusrow=mysql_fetch_array($statusquery);
    ?>
    <option value="<?php echo $statusrow["status"] ?>"
    <?php
    if ($row['LFour_Yearly_DO_NO']==$statusrow["status"])
    {
    echo "selected";
    }
    ?>
    ><?php echo $statusrow["status"] ?><?php}?></select> </td>
    </tr>





    share|improve this answer






























      0














          I have made the droop down list dynamic and solved the issue...    
      <td><input type="date" class="form-control" name="LFour_Yearly" value="<?php echo $LFour_Yearly; ?>"></td>
      <td><select class="form-control" name="LFour_Yearly_DO_NO"> <option value=""></option>
      <?php
      $statusquery=mysql_query("SELECT * FROM inspection_status");
      $statusrowcount=mysql_num_rows($statusquery);

      for($i=1;$i<=$statusrowcount;$i++)
      {
      $statusrow=mysql_fetch_array($statusquery);
      ?>
      <option value="<?php echo $statusrow["status"] ?>"
      <?php
      if ($row['LFour_Yearly_DO_NO']==$statusrow["status"])
      {
      echo "selected";
      }
      ?>
      ><?php echo $statusrow["status"] ?><?php}?></select> </td>
      </tr>





      share|improve this answer




























        0












        0








        0







            I have made the droop down list dynamic and solved the issue...    
        <td><input type="date" class="form-control" name="LFour_Yearly" value="<?php echo $LFour_Yearly; ?>"></td>
        <td><select class="form-control" name="LFour_Yearly_DO_NO"> <option value=""></option>
        <?php
        $statusquery=mysql_query("SELECT * FROM inspection_status");
        $statusrowcount=mysql_num_rows($statusquery);

        for($i=1;$i<=$statusrowcount;$i++)
        {
        $statusrow=mysql_fetch_array($statusquery);
        ?>
        <option value="<?php echo $statusrow["status"] ?>"
        <?php
        if ($row['LFour_Yearly_DO_NO']==$statusrow["status"])
        {
        echo "selected";
        }
        ?>
        ><?php echo $statusrow["status"] ?><?php}?></select> </td>
        </tr>





        share|improve this answer















            I have made the droop down list dynamic and solved the issue...    
        <td><input type="date" class="form-control" name="LFour_Yearly" value="<?php echo $LFour_Yearly; ?>"></td>
        <td><select class="form-control" name="LFour_Yearly_DO_NO"> <option value=""></option>
        <?php
        $statusquery=mysql_query("SELECT * FROM inspection_status");
        $statusrowcount=mysql_num_rows($statusquery);

        for($i=1;$i<=$statusrowcount;$i++)
        {
        $statusrow=mysql_fetch_array($statusquery);
        ?>
        <option value="<?php echo $statusrow["status"] ?>"
        <?php
        if ($row['LFour_Yearly_DO_NO']==$statusrow["status"])
        {
        echo "selected";
        }
        ?>
        ><?php echo $statusrow["status"] ?><?php}?></select> </td>
        </tr>






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 26 '18 at 14:36

























        answered Nov 26 '18 at 14:30









        SijiSiji

        136




        136
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53480761%2fphp-while-editing-form-field-using-select-default-value-or-previous-value-ge%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            To store a contact into the json file from server.js file using a class in NodeJS

            Redirect URL with Chrome Remote Debugging Android Devices

            Dieringhausen