Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to organize a list returned by a sql query in angular.js
    primarykey
    data
    text
    <p>I apologize if this isn't the best code anyone has ever seen. I'm somewhat new to angular.js.</p> <p>My problem is this: when the data is returned from my query it simply displays as a block of text. In search.php, inserting echo statements simple displays the output of the echo statement instead of generating the code. I can't seem to force the output to behave.</p> <pre><code>$data = file_get_contents("php://input"); $objData = json_decode($data); $db = mysql_connect("xxxxxxxx", "xxxxxxxx", "xxxxxxxx") or die ("Error connecting to database."); mysql_select_db("Awards_New", $db) or die ("Couldn't select the database."); $results = mysql_query('SELECT * FROM Awards WHERE AwardName LIKE "%'. $objData-&gt;data .'%"'); while($row = mysql_fetch_array($results)){ echo $row['AwardName'] . " "; } mysql_close($db); </code></pre> <p>The bit of html...</p> <pre><code>&lt;div ng-controller="SearchCtrl"&gt; &lt;form class="well form-search"&gt; &lt;label&gt;Search:&lt;/label&gt; &lt;input type="text" ng-model="keywords" class="input-medium search-query" placeholder="Keywords..."&gt; &lt;button type="submit" class="btn" ng-click="search()"&gt;Search&lt;/button&gt; &lt;p class="help-block"&gt;Single words only: eg; AFS, University, Geology&lt;/p&gt; &lt;/form&gt; &lt;div ng-model="result"&gt; {{result}} &lt;/div&gt; &lt;/div&gt; </code></pre> <p>and the js... (this is my weakest link)</p> <pre><code>function SearchCtrl($scope, $http) { $scope.url = 'search.php'; $scope.search = function() { $http.post($scope.url, { "data" : $scope.keywords}). success(function(data, status) { $scope.status = status; $scope.data = data; $scope.result = data; }) . error(function(data, status) { $scope.data = data || "Fail."; $scope.status = status; }); }; } </code></pre> <p>What I am trying to do is organize the data in to distinct rows upon retrieval. However, nothing I can do seems to work. At this point, I'm not sure where I should look next for direction to resources and help. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload