How to add a record to a database using id instead of changing them (javascript and php)?

How do I add a few records to a database using the id’s I had listed in phpMyAdmin. The problem is once I entered the id , it display the database but when I entered another id , it took out and change the value of the first id database I entered and replace it with the second id. What I want is to add the database one by one through each click but instead of replacing it, I would like to add them below after the first ID I entered earlier. This is what I’m working on so far.

    <title>Search data by its ID</title>
        <h1>Search a single DATA</h1>
        <h2>Retrieve data from database</h2>

    <div class = "container">
        <form action ="" method = "POST">
            <input type = "text" name ="id" placeholder="Student ID"/>
            <input type = "submit" name="search" value="Search By ID"/>

        <table border ="2">
                    <th>Product Name</th>
                    <th>Returned Date</th>
               $connection = mysqli_connect("localhost","root", "");
               $db = mysqli_select_db($connection,"myfirstdb");

                   $id = $_POST['id'];

                   $query = "SELECT * FROM `table3` where id = '$id'";
                   $query_run = mysqli_query($connection, $query);

                   while($row = mysqli_fetch_array($query_run))
                           <td><?php echo $row ['product_name']; ?> </td>
                           <td><?php echo $row ['quantity']; ?> </td>
                           <td><?php echo $row ['returned_date']; ?> </td>




Your code isn’t adding anything to the database?
It lets you type an id, reads the row with that id from the database and displays the data.

I would suggest you google php / mysql CRUD (Create, Read, Update, Delete) scripts as it honestly appears you are not fully understanding what you want to do and confusing Phpmyadmin with a database

To be fair, that’s not at all uncommon, I’ve noticed quite a few questions on another site talk about storing stuff in phpmyadmin.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.