Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8417637
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T02:06:38+00:00 2026-06-10T02:06:38+00:00

I wish to display data from mysql database using angularJS but all in vain.

  • 0

I wish to display data from mysql database using angularJS but all in vain. Please review my code and suggest me where am I going wrong ?

  <?php
    $host = "localhost"; 
    $user = ""; 
    $pass = ""; 
    $database = "abc";
    $con = mysql_connect($host,$user,$pass);
    if (!$con) {
        die('Could not connect: ' . mysql_error());
    }
    echo 'Connected successfully'; 
    mysql_select_db($database,$con);  
     //select
    $query = "SELECT * FROM `product`"; 
    $result = mysql_query($query) OR die(mysql_error()); 
    $arr = array();
    //now we turn the results into an array and loop through them. 
    while ($row = mysql_fetch_array($result)) { 
        $name = $row['name']; 
        $description = $row['description']; 
        //echo 'This is: ' . $name . ' ' . $description . "<br/>\n"
        $arr[] = $row;
    } 
    echo json_encode($arr);
?>

controllers.js

 function ProductListCtrl($scope,$http) {
    $http.get('php/connect.php').success(function(data) {
        $scope.products = data;
    });
    //$scope.orderProp = 'name';

}

index.html

    <html ng-app>
    <head>
        <script src="../angular-1.0.1.min.js"></script>
        <script src="js/controllers.js"></script>
    </head>
    <body>
    <ul ng:controller="ProductListCtrl">
        <li ng:repeat="product in products">
            {{product.name}}
        </li>
    </ul>
    </body>
</html>

When I run index.html, I get infinite list of bullets with no result displayed.

Where am I going wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T02:06:40+00:00Added an answer on June 10, 2026 at 2:06 am

    I agree with Alexander, if you can get JSON data from your browser console that would help.

    I think you wanted to do something like this in your php code to get only name and description
    $arr[] = array('name' => $name, 'description' => $description); instead of $arr[] = $row;

    You may be getting back an error from your php code in the form of html and $http is pulling this apart as if it were an array.

    hope this helps

    –dan

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a database with 2 tables I wish to pull data from both
I have this code that fetches data from mySQL and outputs it as an
I am using a jquery modal dialog to display a table of data from
Hi I am using Crystal Reports 10 with IIS Server. I wish to display
I wish to use QtWebKit to load a url for display, but, that's the
I have exported my sql statements from phpmyadmin 'data.sql'. I wish to reverse engineer
How do I grab meta data from other websites and display on mine in
I wish to add data to a comboboxlist but am unsure of the correct
i have try to develop one java app.here am getting information from mysql database.
This is code for get current date information is getting from database. It is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.