I made a function and passed values in it but it does not give any output. Instead of writing the same code for fetching data from different tables, I want to make a function so that just by passing string values of table name code could be executed. Here is my code.
function productTableQuery($selectTable) {
$query = "SELECT * FROM $selectTable";
$result = mysqli_query($connection, $query);
while ($row = mysqli_fetch_assoc($result)) {
$serialNumber = $row['serial_number'];
$particulars = $row['particulars'];
echo "<option value='$serialNumber'>$particulars</option>";
}
}
switch($product_table) {
case 'insert':
productTableQuery("product_insert");
break;
default:
header("Location: index.php");
break;
}