Question

In: Computer Science

This assignment will assess the competency 6. Construct an application that successfully utilizes MySQL features. Directions:...

This assignment will assess the competency 6. Construct an application that successfully utilizes MySQL features. Directions: Create short description of a PHP/MySQL project you could develop. Include a description of how it would be used, why it would be used and how MySQL and a PHP page would interact.

Solutions

Expert Solution

First all the basic details about making connection with database in php and how to use json is explained in detail. If you already know that then fine otherwise just go through it ones. and in the last complete code of given table is given to extract name of states according to given query.

First we will create config.php , which contains database details.

<?php

      $user_name="user";
      $password="pass";
      $mysql:host="localhost";
      $db_name="us_states";

      ?>

To establish db connection, we have to pass various db parameters like:

$con=mysqli_connect($host,$user_name,$password,$db_name);

if($con->connect_error){ die("Connection failed:".$con-->connect_error)

$con ==> will hold handler for db

Now construct sql statements as

$sql="select * from data;";

" put your sql statements within this part ";

Note: we have two semicolon.One for php statement and one for sql statement.

Now to execute sql query we a function in php mysqli_query()

mysqli_query(connection handler,sql query);

$result=mysqli_query($con,$sql);

$result will hold output of sql query

Note:$result may have results from various rows ,it is easier for programmer ,if it in array/json etc formats,to perform various operations.   

Function mysqli_fetch_array(query result) ,will fetch result row by row.

row=mysqli_fetch_array($result))
{

array_push($response,array("name"=>$row["name"],"age"=>$row["age"]));

}

this code will put all result in array fomat in $response variable.

If you want it in json, simply use as

json_encode(array("abc"=>$response));

Important :Don't for forgot to close db connection ,after using it

mysqli_close($con);

To perform different operations, create a operation.php

Operation.php has a code to establish db connection + execute sql query +close db connection

we have to call config.php in php to have access to varios db parameters.

like this

require_once 'config.php';

Complete code to display all results.php

<?php

require_once 'config.php';
$con=mysqli_connect($mysql:host,$user,$pass,$us_states,$min_income, $max_income, $min_home_value, $max_home_value);

$sql="SELECT State FROM economic_data WHERE (MedianIncome BETWEEN $min_income AND $max_income) AND (MedianHomePrice BETWEEN $min_home_value AND $max_home_value) ;";
$result=mysqli_query($con,$sql);

$row=mysqli_fetch_array($result));

$state=$row[State];

echo $state;

mysqli_close($con);
?>


Related Solutions

This assignment will assess the competency 6. Examine how successful leaders enable others to act. Directions:...
This assignment will assess the competency 6. Examine how successful leaders enable others to act. Directions: For this assignment, imagine you are the lead on a new project. You must put together a team of people to complete the project in a timely fashion. Use the information you learned from this learning plan as you answer the following questions: • What is the project? (Could be real or imagined.) • Who is on your team, and why? (Consider the types of people you...
Directions This assignment will assess the competency 1. Evaluate the role of HR, 3. Examine organization...
Directions This assignment will assess the competency 1. Evaluate the role of HR, 3. Examine organization capabilities for human resource management, & 4. Create a human resource capabilities model. As part of understanding the respective theories discussed and applying them to organizations to create a competitive advantage, you will have the opportunity to assess a particular aspect or aspects of the HR strategy at an organization and how the particular strategy supports the organization’s strategic business objectives. An introduction. An...
LP8 Assignment: CMS Director This assignment will assess the competency 8. Evaluate trends that will affect...
LP8 Assignment: CMS Director This assignment will assess the competency 8. Evaluate trends that will affect the long-term care system in the future as well as challenges facing managers in the long-term care system of the future. Prepare a 3-4 page, double-spaced paper (cite 3-4 reliable sources) that addresses the following scenario: You are the newly appointed director of the Center for Medicare and Medicaid Services (CMS). With health care costs continuing to soar, the Medicare Modernization Act (MMA) rollout...
COMPENSATION AND BENEFITS LP2 Assignment: Internal Equity and Job Analysis This assignment will assess the competency...
COMPENSATION AND BENEFITS LP2 Assignment: Internal Equity and Job Analysis This assignment will assess the competency 2. Determine the critical aspects pertaining to the internal alignment of compensation polices and techniques. Directions: Write a paper that addresses the following questions: • Define “internal equity” and explain the reason for its existence and its impact on the organization. • What does job analysis have to do with internal alignment? • What is the critical advantage of quantitative approaches over conventional approaches...
LP7 Assignment: IT System for St. Timothy’s This assignment will assess the competency 7. Analyze potential...
LP7 Assignment: IT System for St. Timothy’s This assignment will assess the competency 7. Analyze potential applications of an information technology system and marketing strategies and the impact of changes in regulations. Prepare a 3-4 page, double-spaced paper (cite 3-4 reliable sources) that addresses the following scenario: You are the Director of Continuing Care Services for St. Timothy’s Health Care System, a multilevel system consisting of an array of acute and long-term services. You have been given the task of...
Assignment 10.1: Milestone 5: Leadership across Cultures Assignment Task: This assignment will assess competency 7. Propose...
Assignment 10.1: Milestone 5: Leadership across Cultures Assignment Task: This assignment will assess competency 7. Propose a Human Resource Management strategy and specific organizational behaviors that are best suited for global business organizations. Directions The due diligence analyses on the three countries chosen in Week 01 will wrap up in this assignment with the exploration of management decision making processes. For each of your countries, you will discuss the benefits bringing the diversity of the workforce will have for your...
LP1 Assignment: Milestone 1: International Expansion This assignment will assess competency 1. Build effective global and...
LP1 Assignment: Milestone 1: International Expansion This assignment will assess competency 1. Build effective global and international linkages for multinational organizations. Directions The company you work for is expanding internationally in the near future. A team of employees, which you are a part, have been given the task of evaluating one developed (not the U.S.), one emerging and one developing country for possible expansion. You will pick three countries this week, using the Dow Jones Indexes, and begin the process...
LP5.1 Assignment: Aging Parents These assignments will assess the competency 5. Analyze reimbursement and quality improvement...
LP5.1 Assignment: Aging Parents These assignments will assess the competency 5. Analyze reimbursement and quality improvement in long-term care systems. Prepare a 3-4 page, double-spaced paper (cite 3-4 reliable sources) that addresses the following scenario: You are helping your parents, ages 62 and 64, plan their retirement and financial future. • Research and discuss options for seniors' long-term care, including programs through Medicare, Medicaid, managed care, and other private insurance, etc. • What will you tell them about the potential...
My topic id police brutality. This assignment will assess the following competency: 7. Develop an annotated...
My topic id police brutality. This assignment will assess the following competency: 7. Develop an annotated bibliography from secondary research. Directions: Now that you have begun your primary research, this week you are going to organize your secondary research and create an annotated bibliography. Read about annotated bibliographies at Purdue Owl. This annotated bibliography will contain sources you have read on your topic that you plan to use in your final paper. The sources must be peer-reviewed. For more information...
his assignment will assess competency 3. Analyze the fundamental characteristics of organizing. Throughout your career, especially...
his assignment will assess competency 3. Analyze the fundamental characteristics of organizing. Throughout your career, especially as a manager, you will have to understand and work in a variety of structural configurations. Changing times may force you to participate or lead a reorganization for your company. It is important to understand the structure and the effect it can have on achieving company goals. For your paper: Research and describe how the scholarly literature describes the functional and divisional approaches to...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT