田辺  亮介

田辺 亮介

1595314140

PHP / MariaDB / 데이터베이스 값 가져와서 출력하기

이 강좌에서 사용하는 데이터베이스는 employees입니다. (employees 설치 하기)

employees 출력하기 - employees.php

employees 테이블에는 직원 목록이 있습니다. 그 목록을 가져와서 출력해보겠습니다.

데이터베이스 연결 정보

employees 데이터베이스에 연결하기 위한 정보를 입력합니다. username과 password는 적절히 변경하세요.

$jb_conn = mysqli_connect( 'localhost', 'username', 'password', 'employees' );

쿼리 작성하기

employees 테이블에서 5개의 레코드를 가져오는 쿼리입니다.

$jb_sql = "SELECT * FROM employees LIMIT 5;";

값 저장하기

쿼리 결과를 담습니다.

$jb_result = mysqli_query( $jb_conn, $jb_sql );

출력하기

필요한 필드를 출력합니다.

while( $jb_row = mysqli_fetch_array( $jb_result ) ) {
  echo '<p>' . $jb_row[ 'emp_no' ] . $jb_row[ 'first_name' ] . $jb_row[ 'last_name' ] . $jb_row[ 'hire_date' ] . '</p>';
}

전체 코드

<!doctype html>
<html lang="ko">
  <head>
    <meta charset="utf-8">
    <title>Employees</title>
  </head>
  <body>
    <?php
      $jb_conn = mysqli_connect( 'localhost', 'username', 'password', 'employees' );
      $jb_sql = "SELECT * FROM employees LIMIT 5;";
      $jb_result = mysqli_query( $jb_conn, $jb_sql );
      while( $jb_row = mysqli_fetch_array( $jb_result ) ) {
        echo '<p>' . $jb_row[ 'emp_no' ] . $jb_row[ 'first_name' ] . $jb_row[ 'last_name' ] . $jb_row[ 'hire_date' ] . '</p>';
      }
    ?>
  </body>
</html>

표로 만들기

표로 출력하도록 변경한 코드입니다. HTML과 CSS만 바뀌었을 뿐, 데이터베이스를 불러오고 출력하는 것은 위와 같습니다.

<!doctype html>
<html lang="ko">
  <head>
    <meta charset="utf-8">
    <title>Employees</title>
    <style>
      body {
        font-family: Consolas, monospace;
        font-family: 12px;
      }
      table {
        width: 100%;
      }
      th, td {
        padding: 10px;
        border-bottom: 1px solid #dadada;
      }
    </style>
  </head>
  <body>
    <table>
      <thead>
        <tr>
          <th>emp_no</th>
          <th>first_name</th>
          <th>last_name</th>
          <th>hire_date</th>
        </tr>
      </thead>
      <tbody>
        <?php
          $jb_conn = mysqli_connect( 'localhost', 'username', 'password', 'employees' );
          $jb_sql = "SELECT * FROM employees LIMIT 5;";
          $jb_result = mysqli_query( $jb_conn, $jb_sql );
          while( $jb_row = mysqli_fetch_array( $jb_result ) ) {
            echo '<tr><td>' . $jb_row[ 'emp_no' ] . '</td><td>'. $jb_row[ 'first_name' ] . '</td><td>' . $jb_row[ 'last_name' ] . '</td><td>' . $jb_row[ 'hire_date' ] . '</td></tr>';
          }
        ?>
      </tbody>
    </table>
  </body>
</html>

#php

What is GEEK

Buddha Community

PHP / MariaDB / 데이터베이스 값 가져와서 출력하기

Hire PHP Developer

Looking to develop a PHP based website from scratch or revamp your existing website?

HourlyDeveloper.io has always been an industry leader for companies and business owners looking to hire PHP web developer. By choosing to Hire PHP Developer from our company, you can always expect the best results. Our PHP services and solutions are always flexible which means that no matter the nature of your project, you can always count on us for getting the best PHP expertise.

Consult with our experts: https://bit.ly/3aEGxPy

#hire php developer #php developer #php development company #php development services #php development #php

Hire PHP Developer - Best PHP Web Frameworks for Web Development

A framework that can drastically cut down the requirement to write original code to develop the web apps as per your requirement is PHP Framework. PHP frameworks offer code libraries for commonly used functions to reduce the development time.

Want to use PHP Web Frameworks for your web applications?

WebClues Infotech offers a service to hire dedicated PHP developers for all of the below-mentioned frameworks

  • Laravel Developer
  • Codeigniter Developer
  • Yii Developer
  • Zend Developer
  • Cake PHP Developer
  • Core PHP Developer

Not sure which framework to use for your PHP web application?

Contact us

Schedule Interview with PHP Developer https://bit.ly/3dsTWf0

Email: sales@webcluesinfotech.com

#hire php developer #hire php web developers #hire php developer in 2021 #hire php developers & dedicated php programmers #hire php developers india #hire and outsource freelance php developers

Mariya James

Mariya James

1613990718

Top PHP web development company| PHP development services India

ValueCoders is a leading PHP app development company that focuses on building robust, secure & scalable web applications for start-ups, enterprises, and entrepreneurs.

We have 16+ years of experience and have delivered custom PHP web development solutions to 2500+ global clients catering industry verticals, including healthcare, adtech, eLearning, data analysis, Fintech, eCommerce, etc

Are you planning to outsource PHP development services? Or want to hire an offshore PHP development team?

#hire php developer #hire a php developer in india #hire dedicated php programmers #hire php coders #php developer in india #php developers for hire

Hire Dedicated PHP Developer

Looking to hire affordable yet experienced PHP developers?

Hire Dedicated PHP Developer, who can convert your idea to reality, within the stipulated time frame. HourlyDeveloper.io expertise & experience as the top PHP development company put us above our competitors, in many ways. We have some of the top PHP developers in the industry, which can create anything you can imagine, that too, at the most competitive prices.

Consult with our experts:- https://bit.ly/2NpKnB8

#hire dedicated php developer #php developers #php development company #php development services #php development #php developer

Custom PHP Development Company | PHP Web Development Service

One programming language that has its root in Website development even at present is PHP Website Development. The PHP programming is executed on the server side which means it functions on web servers which helps the website in its performance.

Want to develop a website on PHP?

WebClues Infotech with its years of experience in Web Development helps individuals and businesses in launching a business website on PHP. The experienced development team with more than 20 years of experience is the solution to your every web development needs.

Want to know more about PHP website development?

Visit: https://www.webcluesinfotech.com/php-web-development/

Share your requirements https://www.webcluesinfotech.com/contact-us/

View Portfolio https://www.webcluesinfotech.com/portfolio/

#custom php development company #php web development service #php development services #php web development company india #php development services #hire php developers