Data from the function is not showing in the select box. When I filter the user with the session ID but data showing without filter by session-id.
******* I used mysqli for login and session***
<?php
$connect = new PDO("mysql:host=localhost;dbname=explore_pos", "root", "");
function fill_supplier_box($conn)
{
$output = '';
$get_user = htmlspecialchars($_SESSION["id"]);
$query = "SELECT * FROM tbl_supplier where userid = $get_user ";
$statement = $conn->prepare($query);
$statement->execute();
$result1 = $statement->fetchAll();
foreach($result1 as $row)
{
$output .= '<option value="'.$row["id"].'">'.$row["name"].'</option>';
}
return $output;
}
?>
Here is HTML part
<select name="supplier_id[]" class="form-control supplier_id">
<option value="">----</option>
<?php echo fill_supplier_box($connect); ?>
</select>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…