I'm trying to print ñ in select option from SQL and PHP using ODBC connection. My problem is the ñ prints � in the select option. How can i fix this issue?
$dbconn = odbc_connect("Driver={SQLServer};Server=server;DATABASE=database;", "username", "password");
$query = "SELECT * FROM SchoolInformation ORDER BY SchName ASC";
$resultfunc = odbc_exec($dbconn, $query);
<select>
<?php while($resultrow = odbc_fetch_array($resultfunc)){ ?>
<option><?php echo $resultrow['SchName']; ?></option>
<?php } ?>
</select>
This is a character encoding issue. You need to set the character encoding you want at multiple levels (PHP, database and html output).
Please see this reference for more info: https://phpbestpractices.org/#utf-8
(Note this talks about MySQL, but character encoding and collation are something you need to consider when working with any database.)