How to view the database on the php website:
Recommended: php server
Connect to the database code:
<?php define("DB_HOST","localhost"); define("DB_USER","root"); define("DB_PWD",""); define("DB_NAME","wordpress4"); $conn = @mysql_connect(DB_HOST,DB_USER,DB_PWD) or die("连接服务器出错:".mysql_error()); @mysql_select_db(DB_NAME) or die("连接数据库出错:".mysql_error()); @mysql_query('SET NAMES UTF8'); ?>
Read database information code:
$result = mysql_query("select * from wp_wf order by timer02 desc limit 0,50");//获取最新50条数 while($row = mysql_fetch_array($result))//转成数组,且返回第一条数据,当不是一个对象时候退出 { echo ' <div class="cp_haoma_list cat-list"> <h2 id="数据详情-label-row-number-label">数据详情<label>'.$row['number02'].'</label></h2> <div class="haoma_con"><span>'. str_ireplace(",","</span><span>",$row['datar02']) .'</span> </div> </div>'; }
Code to close the database:
mysql_close($conn);
By combining the three pieces of code, PHP can read the database and display it to the front desk of the website. The code is as follows:
<?php require "conn.php";//连接数据库 $result = mysql_query("select * from wp_kaijiangwf order by timer02 desc limit 0,50");//最新50条数 while($row = mysql_fetch_array($result))//转成数组,且返回第一条数据,当不是一个对象时候退出 { echo ' <div class="cp_haoma_list cat-list"> <h2 id="数据详情-label-row-number-label">数据详情<label>'.$row['number02'].'</label></h2> <div class="haoma_con"><span>'. str_ireplace(",","</span><span>",$row['datar02']) .'</span> </div> </div>'; } mysql_close($conn);// 关闭数据库 ?>
The above is the detailed content of How to check the database on php website. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 Mac version
God-level code editing software (SublimeText3)

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool
