So i have written this code -
$result = mysqli_query($con,"SELECT * FROM Appointments");
echo "<table border='1'>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Address</th>
<th>City</th>
<th>PIN</th>
<th>Mobile</th>
</tr>";
while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['FirstName'] . "</td>";
echo "<td>" . $row['LastName'] . "</td>";
echo "<td>" . $row['Address'] . "</td>";
echo "<td>" . $row['City'] . "</td>";
echo "<td>" . $row['PIN'] . "</td>";
echo "<td>" . $row['Mobile'] . "</td>";
echo "</tr>";
}
echo "</table>";
But if i want to execute -
SELECT FirstName, Address FROM Appointments WHERE LastName='Something'
How can i do that? How can i display just two columns? I can do that manually by changing the table in file.
But how can we change the table according to the query requested? So if two columns were requested then only two columns will be displayed.