0

Is that possible to select variable in DB (such as : $username) and display their info in textbox ?

Example:

Select : $username

after the selection, in the text input , will show: $username , $usernameEmail , $usernameContactNumber

and click on "Register", it will insert to database with the information

I have no idea how does this work. I have no problem in inserting value to database.

The only problem that I am unable to solve right now is the condition I needed.

When I choose $username (example: userA), all the information of userA will be appearing in the text input below

$query = "SELECT * FROM userdatabase";
$result1 = mysqli_query($db,$query);

<select>
    <?php while($row1 = mysqli_fetch_array($result1)):; ?>
    <option value="<?php echo $row1[0];?>"><?php echo $row1[2];?></option>
    <?php endwhile;?>
</select>

The code above is the selection (PHP

<script>
$(document).ready(function(){
    $("form#get").submit(function(event) {
        event.preventDefault();
        var input = $("#username");

        $.ajax({
            type: "POST",
            url: "userregisteraccount.php",
            success: function(data) { input.val(data); }
        });
    });
});
</script>

code above is the ajax so that when i choose "userName" , "userName" data will be show in the registerform

5
  • 2
    Welcome to Stackoverflow. Maybe take a look at Ajax. It’s a library for easy asynchron requests. Here a well known intro: w3schools.com/xml/ajax_intro.asp Commented Apr 20, 2019 at 8:05
  • followed the w3school example , unable to do it , it show option values , but when i selected , the info wont change Commented Apr 20, 2019 at 8:24
  • Read carefully the question and the accepted answer here - stackoverflow.com/questions/41964536/…. Commented Apr 20, 2019 at 8:34
  • Please share us your code. So we can help you better Commented Apr 20, 2019 at 8:35
  • i have the updated my code in the first post @Markus Commented Apr 20, 2019 at 8:44

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.