Skip to main content
update wording
Source Link

I am wondering ifIs the method I am usingused below to get data from a database is efficient and optimal.? The data is in a MySQL database, and in my server I have a PHP file with the following code to return some information:

if($_POST["method"] == "requestBusinessFood") {
    requestBusinessFood();
} 

function requestBusinessFood() {
    $categoryID = $_POST["category"];

    $host = 'localhost';
    $user = 'root';
    $pass = '';
    $db = 'fooddatabase';

    $conn = mysqli_connect($host, $user, $pass, $db); 
        $sql = "SELECT * FROM `foodtablebusiness` WHERE category = " . $categoryID;

        $result = mysqli_query($conn, $sql);
        $rows = array();
        while($r = mysqli_fetch_assoc($result)) {
         $rows[] = $r;
        }

        echo json_encode($rows);
}

On the webpage, I have a js file to retrieve the information in the following way:

  function createAJAXRequestToPopulateList(category) {
    return $.ajax({ url: '../server.php',
                    data: {method: 'requestBusinessFood',
                           category: category},
                    type: 'post'
    });
  }

function addActivityItem(){
    var selector = document.getElementById("categorySelector");
    ajaxRequest = createAJAXRequestToPopulateList(selector.options[selector.selectedIndex].value);
    ajaxRequest.done(populateList);
}

function populateList(responseData) {
    console.log(responseData);
}

I am wondering if the method I am using to get data from a database is efficient and optimal. The data is in a MySQL database, and in my server I have a PHP file with the following code to return some information:

if($_POST["method"] == "requestBusinessFood") {
    requestBusinessFood();
} 

function requestBusinessFood() {
    $categoryID = $_POST["category"];

    $host = 'localhost';
    $user = 'root';
    $pass = '';
    $db = 'fooddatabase';

    $conn = mysqli_connect($host, $user, $pass, $db); 
        $sql = "SELECT * FROM `foodtablebusiness` WHERE category = " . $categoryID;

        $result = mysqli_query($conn, $sql);
        $rows = array();
        while($r = mysqli_fetch_assoc($result)) {
         $rows[] = $r;
        }

        echo json_encode($rows);
}

On the webpage, I have a js file to retrieve the information in the following way:

  function createAJAXRequestToPopulateList(category) {
    return $.ajax({ url: '../server.php',
                    data: {method: 'requestBusinessFood',
                           category: category},
                    type: 'post'
    });
  }

function addActivityItem(){
    var selector = document.getElementById("categorySelector");
    ajaxRequest = createAJAXRequestToPopulateList(selector.options[selector.selectedIndex].value);
    ajaxRequest.done(populateList);
}

function populateList(responseData) {
    console.log(responseData);
}

Is the method used below to get data from a database efficient and optimal? The data is in a MySQL database, and in my server I have a PHP file with the following code to return some information:

if($_POST["method"] == "requestBusinessFood") {
    requestBusinessFood();
} 

function requestBusinessFood() {
    $categoryID = $_POST["category"];

    $host = 'localhost';
    $user = 'root';
    $pass = '';
    $db = 'fooddatabase';

    $conn = mysqli_connect($host, $user, $pass, $db); 
        $sql = "SELECT * FROM `foodtablebusiness` WHERE category = " . $categoryID;

        $result = mysqli_query($conn, $sql);
        $rows = array();
        while($r = mysqli_fetch_assoc($result)) {
         $rows[] = $r;
        }

        echo json_encode($rows);
}

On the webpage, I have a js file to retrieve the information in the following way:

  function createAJAXRequestToPopulateList(category) {
    return $.ajax({ url: '../server.php',
                    data: {method: 'requestBusinessFood',
                           category: category},
                    type: 'post'
    });
  }

function addActivityItem(){
    var selector = document.getElementById("categorySelector");
    ajaxRequest = createAJAXRequestToPopulateList(selector.options[selector.selectedIndex].value);
    ajaxRequest.done(populateList);
}

function populateList(responseData) {
    console.log(responseData);
}
Update wording
Source Link

I am wondering if the method I am using to get data from a database is efficient and optimal. I have myThe data is in a MySQL database, and in my server I have a PHP file with the following code to return some information:

if($_POST["method"] == "requestBusinessFood") {
    requestBusinessFood();
} 

function requestBusinessFood() {
    $categoryID = $_POST["category"];

    $host = 'localhost';
    $user = 'root';
    $pass = '';
    $db = 'fooddatabase';

    $conn = mysqli_connect($host, $user, $pass, $db); 
        $sql = "SELECT * FROM `foodtablebusiness` WHERE category = " . $categoryID;

        $result = mysqli_query($conn, $sql);
        $rows = array();
        while($r = mysqli_fetch_assoc($result)) {
         $rows[] = $r;
        }

        echo json_encode($rows);
}

On the webpage, I have a js file to retrieve the information in the following way:

  function createAJAXRequestToPopulateList(category) {
    return $.ajax({ url: '../server.php',
                    data: {method: 'requestBusinessFood',
                           category: category},
                    type: 'post'
    });
  }

function addActivityItem(){
    var selector = document.getElementById("categorySelector");
    ajaxRequest = createAJAXRequestToPopulateList(selector.options[selector.selectedIndex].value);
    ajaxRequest.done(populateList);
}

function populateList(responseData) {
    console.log(responseData);
}

I am wondering if the method I am using to get data from a database is efficient and optimal. I have my data in MySQL database, and in my server I have a PHP file with the following code to return some information:

if($_POST["method"] == "requestBusinessFood") {
    requestBusinessFood();
} 

function requestBusinessFood() {
    $categoryID = $_POST["category"];

    $host = 'localhost';
    $user = 'root';
    $pass = '';
    $db = 'fooddatabase';

    $conn = mysqli_connect($host, $user, $pass, $db); 
        $sql = "SELECT * FROM `foodtablebusiness` WHERE category = " . $categoryID;

        $result = mysqli_query($conn, $sql);
        $rows = array();
        while($r = mysqli_fetch_assoc($result)) {
         $rows[] = $r;
        }

        echo json_encode($rows);
}

On the webpage, I have a js file to retrieve the information in the following way:

  function createAJAXRequestToPopulateList(category) {
    return $.ajax({ url: '../server.php',
                    data: {method: 'requestBusinessFood',
                           category: category},
                    type: 'post'
    });
  }

function addActivityItem(){
    var selector = document.getElementById("categorySelector");
    ajaxRequest = createAJAXRequestToPopulateList(selector.options[selector.selectedIndex].value);
    ajaxRequest.done(populateList);
}

function populateList(responseData) {
    console.log(responseData);
}

I am wondering if the method I am using to get data from a database is efficient and optimal. The data is in a MySQL database, and in my server I have a PHP file with the following code to return some information:

if($_POST["method"] == "requestBusinessFood") {
    requestBusinessFood();
} 

function requestBusinessFood() {
    $categoryID = $_POST["category"];

    $host = 'localhost';
    $user = 'root';
    $pass = '';
    $db = 'fooddatabase';

    $conn = mysqli_connect($host, $user, $pass, $db); 
        $sql = "SELECT * FROM `foodtablebusiness` WHERE category = " . $categoryID;

        $result = mysqli_query($conn, $sql);
        $rows = array();
        while($r = mysqli_fetch_assoc($result)) {
         $rows[] = $r;
        }

        echo json_encode($rows);
}

On the webpage, I have a js file to retrieve the information in the following way:

  function createAJAXRequestToPopulateList(category) {
    return $.ajax({ url: '../server.php',
                    data: {method: 'requestBusinessFood',
                           category: category},
                    type: 'post'
    });
  }

function addActivityItem(){
    var selector = document.getElementById("categorySelector");
    ajaxRequest = createAJAXRequestToPopulateList(selector.options[selector.selectedIndex].value);
    ajaxRequest.done(populateList);
}

function populateList(responseData) {
    console.log(responseData);
}
The database service is MySQL; “phpMyAdmin is a free software tool written in PHP, intended to handle the administration of MySQL over the Web.”
Source Link

I am wondering if the method I am using to get data from a database is efficient and optimal. I have my data in phpmyadminMySQL database, and in my server I have a PHP file with the following code to return some information:

if($_POST["method"] == "requestBusinessFood") {
    requestBusinessFood();
} 

function requestBusinessFood() {
    $categoryID = $_POST["category"];

    $host = 'localhost';
    $user = 'root';
    $pass = '';
    $db = 'fooddatabase';

    $conn = mysqli_connect($host, $user, $pass, $db); 
        $sql = "SELECT * FROM `foodtablebusiness` WHERE category = " . $categoryID;

        $result = mysqli_query($conn, $sql);
        $rows = array();
        while($r = mysqli_fetch_assoc($result)) {
         $rows[] = $r;
        }

        echo json_encode($rows);
}

On the webpage, I have a js file to retrieve the information in the following way:

  function createAJAXRequestToPopulateList(category) {
    return $.ajax({ url: '../server.php',
                    data: {method: 'requestBusinessFood',
                           category: category},
                    type: 'post'
    });
  }

function addActivityItem(){
    var selector = document.getElementById("categorySelector");
    ajaxRequest = createAJAXRequestToPopulateList(selector.options[selector.selectedIndex].value);
    ajaxRequest.done(populateList);
}

function populateList(responseData) {
    console.log(responseData);
}

I am wondering if the method I am using to get data from a database is efficient and optimal. I have my data in phpmyadmin database, and in my server I have a PHP file with the following code to return some information:

if($_POST["method"] == "requestBusinessFood") {
    requestBusinessFood();
} 

function requestBusinessFood() {
    $categoryID = $_POST["category"];

    $host = 'localhost';
    $user = 'root';
    $pass = '';
    $db = 'fooddatabase';

    $conn = mysqli_connect($host, $user, $pass, $db); 
        $sql = "SELECT * FROM `foodtablebusiness` WHERE category = " . $categoryID;

        $result = mysqli_query($conn, $sql);
        $rows = array();
        while($r = mysqli_fetch_assoc($result)) {
         $rows[] = $r;
        }

        echo json_encode($rows);
}

On the webpage, I have a js file to retrieve the information in the following way:

  function createAJAXRequestToPopulateList(category) {
    return $.ajax({ url: '../server.php',
                    data: {method: 'requestBusinessFood',
                           category: category},
                    type: 'post'
    });
  }

function addActivityItem(){
    var selector = document.getElementById("categorySelector");
    ajaxRequest = createAJAXRequestToPopulateList(selector.options[selector.selectedIndex].value);
    ajaxRequest.done(populateList);
}

function populateList(responseData) {
    console.log(responseData);
}

I am wondering if the method I am using to get data from a database is efficient and optimal. I have my data in MySQL database, and in my server I have a PHP file with the following code to return some information:

if($_POST["method"] == "requestBusinessFood") {
    requestBusinessFood();
} 

function requestBusinessFood() {
    $categoryID = $_POST["category"];

    $host = 'localhost';
    $user = 'root';
    $pass = '';
    $db = 'fooddatabase';

    $conn = mysqli_connect($host, $user, $pass, $db); 
        $sql = "SELECT * FROM `foodtablebusiness` WHERE category = " . $categoryID;

        $result = mysqli_query($conn, $sql);
        $rows = array();
        while($r = mysqli_fetch_assoc($result)) {
         $rows[] = $r;
        }

        echo json_encode($rows);
}

On the webpage, I have a js file to retrieve the information in the following way:

  function createAJAXRequestToPopulateList(category) {
    return $.ajax({ url: '../server.php',
                    data: {method: 'requestBusinessFood',
                           category: category},
                    type: 'post'
    });
  }

function addActivityItem(){
    var selector = document.getElementById("categorySelector");
    ajaxRequest = createAJAXRequestToPopulateList(selector.options[selector.selectedIndex].value);
    ajaxRequest.done(populateList);
}

function populateList(responseData) {
    console.log(responseData);
}
capitalize acronym; add tags
Source Link
Loading
Source Link
Loading