I am using HTML
as my base and my file is called index.php
- I have a secondary .php
page called PHPSyntax.php
that holds php
functions in it. How from within index.php
can I call a function from phpsyntax.php
and return the result to index.html
File structure is like this: Index.php
<html>
<body>
<h4>PHP Testing</h4>
<form>
<select>
<option value="null" selected="selected"></option>
//here is where I want to call and return the values from my php
</form>
</body>
</html>
And my PHPSyntax.php
reads like this
<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "test";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); }
$sql = "Select name As 'employeename' from employees";
$result = $conn->query($sql);
if ($result->num_rows > 0)
{
while($row = $result->fetch_assoc()) { echo "<option value=".$row['employeename'].">".$row['employeename']."</option><br>"; }
}
else echo "<option value='null'>default</option>";
$conn->close();
?>