Defines constant for connection to database
define("DB_SERVER", "127.0.0.1");
define("DB_USER", "chutnej_app");
define("DB_PASS", "1234");
define("DB_NAME", "chutnej");
Create a database connection
$connection = mysqli_connect(DB_SERVER, DB_USER, DB_PASS, DB_NAME);
This is table in mysql
CREATE TABLE category (
category_id INT NOT NULL AUTO_INCREMENT,
category_name VARCHAR(255) UNIQUE,
PRIMARY KEY (category_id)
)
ENGINE = InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;
Populate table with some data:
INSERT INTO category (category_name) VALUES ('Reportáže'), ('Rozhovory'), ('Místa');
This functions I call to select above data from the table
function get_category() {
global $connection;
$query = "SELECT * FROM category";
$categories = mysqli_query($connection, $query);
confirm_query($categories);
while($category = mysqli_fetch_array($categories)) {
echo "<option value=\"{$category['category_id']}\">{$category['category_name']} </option>";
}
}
Result:
<li>
<label for="article_category">Druh článku:</label><br />
<select name="article_category" id="article_category" type="text">
<option value="3">M�sta</option><option value="1">Report��e</option><option value="2">Rozhovory</option>
</select>
</li>
Thats what i get in the broswer, All browsers do this. Encoding in broswer is set to UTF-8. Could anyone explain me what is causing the problem? Atleast aim me to right direction, that would be enough:) I thought that just by specifying UTF8 in CREATE TABLE
statement I would solve encoding problems.