I'm creating a mobile app with the Ionic Framework. I got all the html pages created online. Now i want some backend code to get data from a sql server. Receiving the data is no problem with php. But when I use php pages I don't have the interface I created with Ionic.
How can I use php pages (instead of html) and still get the lay out from ionic? Example: my scorebord.php
<?php
$servername = "localhost:3306";
$username = "ssss";
$password = "dffd";
$dbname = "ddddd";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT user_username,user_city,user_highscore FROM tbl_user";
$result = $conn->query($sql);
?>
<ion-view style="" title="Scorebord">
<ion-content class="has-header" overflow-scroll="true" padding="true" style="background: url(img/hX1ml1TVGgABo3ENE6Qg_menu3.png) no-repeat center;">
<h1 style="">Scorebord</h1>
<table style="width:100%">
<?php
if ($result->num_rows > 0) {
// output data of each row
while ($row = $result->fetch_assoc()) {
?>
<tr>
<td><?php echo $row["user_username"] ?></td>
</tr>
<?php
}
} else {
echo "0 results";
}
$conn->close();
?>
</table>
</ion-content>
</ion-view>
btw: Is it safe to just configure my database in a php file like that? Anyone a good alternative?
$httpor$resource. It is not hard, you can find many tutorials on this topic.