I am trying to use php to check if two strings are matching, if they do, then do something. But my if statement keeps returning false, even though they match. Look at my VIEW file. before the if statement, I even used echo just to see what they are.
What am I missing? Is it something to do with angularjs???
<!-- The View -->
<body ng-app"myApp">
<div class="container testing" ng-controller="feedControl">
<table>
<tr ng-repeat="post in posts">
<td style="padding:15px"></td>
<td style="padding:15px"></td>
<td style="padding:15px"></td>
<td style="padding:15px"></td>
<td style="padding:15px">
<?php
$type = '';
echo $type . " " . '';
if($type == 'image'){
echo $type . " " . '';
};
?>
</td>
</tr>
</table>
<br>
</div>
</body>
<!-- feed.php -->
<?php
include 'db.php';
connection();
$sql = "SELECT * FROM feed ORDER BY time DESC";
$result = $conn->query($sql);
$outp = "";
while($rs = $result->fetch_array(MYSQLI_ASSOC)) {
if ($outp != "") {$outp .= ",";}
$source = "";
if($rs["post_type"] == "video"){
$source = str_replace('<iframe width="560" height="315" src="', '', $rs["src"]);
$source = str_replace('" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>', '', $source);
}
if($rs["post_type"] == "music"){
$source = str_replace('<iframe width="100%" height="300" scrolling="no" frameborder="no" allow="autoplay" src="', '', $rs["src"]);
$source = str_replace('"></iframe>', '', $source);
}
if($rs["post_type"] == "image"){
$source = $rs["src"];
}
$outp .= '{"postType":"' . $rs["post_type"] . '",';
$outp .= '"postDate":"' . $rs["time"] . '",';
$outp .= '"postTitle":"' . $rs["post_title"] . '",';
$outp .= '"src":"' . $source . '",';
$outp .= '"postDescription":"'. $rs["post_description"] . '"}';
}
$outp ='{"records":['.$outp.']}';
connectionClose();
echo($outp);
?>
<!-- module -->
var app = angular.module("myApp", ["ngRoute"]);
<!-- controller -->
app.controller('feedControl', function($scope, $http) {
$http.get("pages/db_section/feed.php")
.then(function (response) {
$scope.posts = response.data.records;
});
});
Aucun commentaire:
Enregistrer un commentaire