显示特定记录的详细信息

I want to display details of a particular record that the user enters into the searchbox and store it into an HTML table, once the user clicks on the button.

However, I'm not able to figure out what condition is required for the same. Please help.

My PHP code is:

<?php
                $calldetails = $_POST["call"];
                $link = mysqli_connect("server_name","username","password","database_name") or die("Error: Unable to connect:". mysqli_connect_error());
                if($calldetails)
                {
                    $sql = "select * from table_name";
                    if($result = mysqli_query($link,$sql))
                    {
                        if(mysqli_num_rows($result)>0)
                        {
                            echo "<table class='table table-stripped table-hover table-condensed table-border'>
                                <tr>
                                  <th>Mobile Number</th>
                                  <th>Called Number</th>
                                  <th>Date and Time of Call</th>
                                  <th>Duration</th>
                                  <th>Date of Last Recharge</th>
                                  <th>Amount of Last Recharge</th>
                                </tr>";
                            while($row = mysqli_fetch_array($result, MYSQLI_ASSOC))
                            {
                                echo "<tr>";
                                echo "<td>" .$row["Mobile"] . "</td>";
                                echo "<td>" .$row["Called_Num"] . "</td>";
                                echo "<td>" .$row["Date_Time"] . "</td>";
                                echo "<td>" .$row["Duration"] . "</td>";
                                echo "<td>" .$row["Last_recharge"] . "</td>";
                                echo "<td>" .$row["Amount"] . "</td>";
                                echo "</tr>";
                            }
                                echo "</table>";
                                mysqli_free_result($result);
                            }
                            else
                                echo "mySQL returned an empty result set.";
                        }
                    }
            ?>

Also, I want to display an alert if the user doesn't enter anything in the searchbox. My code displays the records even on empty search. Please tell what condition am I missing.

P.S. I'm new to PHP, and still in the learning phase.

If you execute $sql = "select * from table_name"; It will return the entire Table. Even if the user enters nothing in the search box!

On your code you are getting some POST data $calldetails = $_POST["call"];. If you want to display data related to $calldetails. Use WHERE Condition

Example : SELECT * FROM table_name WHERE column_name = $calldetails

Your query "select * from table_name" will always return the entire table, no matter what the user enters into the searchbox.

Consider using a WHERE clause to filter your results.

you have fire query "select * from table" instead of that you have to pass parameters from search box select * from tablename where " " ; suppose you are taking name from search box so do it like this $name=$_POST['NAME_OF_SEARCH_BOX']; then fire query select * from tablename where name=$name; something like this