0

I have two tables. The table "account_type" is the table where all my options are stored. The table "gebruikers" is the table where i update the value type from the dropdown list fetched from table "account_type". My problem is when I submited my query the selected value is not shown in the dropdownlist. What am i doing wrong? There are no syntax errors. The form simply is not showing the stored value form gebruikers table.

Select dropdownlist:

$stmt = $mysqli->prepare("SELECT 
    a.type, 
    a.type_name,
    a.id,
    b.update_type
    FROM account_type a 
    LEFT JOIN gebruikers b ON b.update_type = a.type 
    GROUP BY a.type_name ORDER BY a.id ASC");

    $stmt->execute();
    $result = $stmt->get_result(); //only works when nd_mysli is set on the server!
    $accounttype = '';
    $accounttype .= '<option value="'.htmlspecialchars($row["update_type"]).'">'.htmlspecialchars($row["type_name"]).'</option>';
    $accounttype .= '<option value="">-- No Type --</option>';
    
    
    while ($row = $result->fetch_assoc()) {
    $accounttype .= '<option value="'.htmlspecialchars($row["type"]).'">'.htmlspecialchars($row["type_name"]).'</option>';
    }
    $stmt->close(); 

The form

<select name="purpose" id="purpose" style="width:170px !important;font-weight: normal !important;" class="form-control">  
    <option value=<?= $accounttype ?>></option></select> 
newtocss
  • 31
  • 5
  • Are you sure the query produces any results? Maybe it is not the PHP fault but the SQL? – Dharman Nov 17 '20 at 23:46
  • Please make sure that you have error reporting correctly set: [How to get the error message in MySQLi?](https://stackoverflow.com/a/22662582/1839439) – Dharman Nov 17 '20 at 23:47

0 Answers0