Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
440 views
in Technique[技术] by (71.8m points)

function - Problem in getting data in selected option using PHP Funcition

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>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...