Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8166005
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T19:42:45+00:00 2026-06-06T19:42:45+00:00

I am very new to PHP and MySql. Is there any method by which

  • 0

I am very new to PHP and MySql. Is there any method by which using PHP script taking value through input box can we set the default value of the column using an update query with this value, rather than alter table function?

Update 1:

I want whatever value I send through my form to become default value of that column. There will be some other columns, whose values should change and not set as default, while other default values should appear in the input box for further updating.

For example, there are 3 columns: A, B, C. Column A has currdate value. Columns B and C are some integer values. Say a user opens the form, he sees the currdate is 02-07-2012 for the column A. Then he enters some values: B = 5, C = 6. The next day when the user opens the form, the currdate will become 03-07-2012. Simultaneously the value of B and C will automatically change from null to 5 and 6, with previous row value the same as default value.

So is it possible that every new row takes the previous value entered from the form as the default value of the column set in the mysql table?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T19:42:47+00:00Added an answer on June 6, 2026 at 7:42 pm

    As I understood You have input fields which update MySQL table. And You have some information in database which will be updated. And fields which are not filled, are not updated in mysql, so it does not empty rows? If that, You could get data from database, then after submitting a form, check whether field is empty and if field is empty, add to that field value which was got from database.

    <?php
    $sql = "SELECT * FROM users WHERE id = 1";
    $result = $dbh->query($sql);
    $data = $result->fetch_assoc();
    ?>
    <form action="#" method="post" id="form">
    <input type="text" id="name" class="aa"/>
    <input type="text" id="email" class="aa"/>
    <input type="button" id="subm" value="Update" />
    </form>
    <script>
    $(document).ready(function () {
        $("#subm").click(function () {
            $(".aa").each(function () {
                var value = $(this).val();
                if (value == "") {
                    var id = $(this).attr("id");
                    $("#"+id).attr("value", "<?=$data['"+id+"']?>");
                }
            });
            $("#form").submit();
        });
    });
    </script>
    

    I dont remember how I could go through each input, so I added class, which is not good. Search in google – each loop for input field jquery.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm very new to using mysql with php, and here's what i found online
I am VERY new to PHP, I'm currently working on a service, part which
I know the title isn't very clear. I'm new to PHP, so there might
Hey there guys and gals. I'm very new to php and am following various
I'm very new to php/MySQL and I'm having a bit of trouble. Help would
I am very new to PHP and MySQL and I have some questions. First,
Is there any way to turn on driver logging for PHP/MySQL 5? Is there
I am very new to PHP & MySQL. Just designing websites for friends as
i am very new to PHP and MySQL. I am trying to write a
I'm very new to using MySql and am having trouble retrieving values from my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.