qu" /> qu">
Home Backend Development PHP Tutorial 获取表内总数。解决方法

获取表内总数。解决方法

Jun 13, 2016 pm 01:13 PM
db query quot select

获取表内总数。

PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->    public  function count(){
        $db=new Db();
        $db->connect();
        $query="select count(*) from wenzhang";
        $shuju=$db->query($query);
        $db->close();
        return $shuju;

    }
Copy after login


可以为什么我在调用页面接受不到呢?



DB类的query语句
PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->public function query($query)    //发送sql语句 insert update select
        {
            $this->result=mysql_query($query);
        }
        
Copy after login


------解决方案--------------------
通常情况下 要用 mysql_fetch_array() 将结果集转化为数组对吧,你的代码中没有啊

$query="select count(*) from wenzhang";
$shuju=$db->query($query);
$row= mysql_fetch_array($shuju);
$db->close();
return $row[0];
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Comparative analysis of Oracle and DB2 database technology Comparative analysis of Oracle and DB2 database technology Mar 11, 2024 am 09:54 AM

Oracle and DB2 are two well-known relational database management systems (RDBMS) that are widely used in enterprise applications. In this article, we will compare the two database technologies of Oracle and DB2 and analyze them in detail, including analysis of their characteristics, performance, functions and usage examples. 1. Overview of Oracle database technology Oracle is a relational database management system developed by Oracle Corporation of the United States. It is widely used in enterprise-level applications and has strong performance and stability.

Comparison and differences of SQL syntax between Oracle and DB2 Comparison and differences of SQL syntax between Oracle and DB2 Mar 11, 2024 pm 12:09 PM

Oracle and DB2 are two commonly used relational database management systems, each of which has its own unique SQL syntax and characteristics. This article will compare and differ between the SQL syntax of Oracle and DB2, and provide specific code examples. Database connection In Oracle, use the following statement to connect to the database: CONNECTusername/password@database. In DB2, the statement to connect to the database is as follows: CONNECTTOdataba

Comparative analysis of Oracle and DB2 database performance Comparative analysis of Oracle and DB2 database performance Mar 09, 2024 pm 10:00 PM

Oracle and DB2 databases are two leading relational database management systems that are widely used in enterprise-level applications. In practical applications, database performance is often one of the important indicators for evaluating the quality of a database system. This article will conduct a comparative analysis of the performance of Oracle and DB2 databases, and use specific code examples to demonstrate the differences between them. 1. Oracle database performance analysis Oracle database is a powerful database management system with good scalability and stability.

What file format is db? What file format is db? May 19, 2021 am 11:56 AM

db is the abbreviation of "datebase", which is a format of "database file". It is a file used by software to store data, which is equivalent to a database. Each software has its own storage format. For example, "Thumbs.db" under Win7 system is a thumbnail data file, so the db file is not a specific file format.

Asynchronous processing method of Select Channels Go concurrent programming using golang Asynchronous processing method of Select Channels Go concurrent programming using golang Sep 28, 2023 pm 05:27 PM

Asynchronous processing method of SelectChannelsGo concurrent programming using golang Introduction: Concurrent programming is an important area in modern software development, which can effectively improve the performance and responsiveness of applications. In the Go language, concurrent programming can be implemented simply and efficiently using Channels and Select statements. This article will introduce how to use golang for asynchronous processing methods of SelectChannelsGo concurrent programming, and provide specific

How to hide the select element in jquery How to hide the select element in jquery Aug 15, 2023 pm 01:56 PM

How to hide the select element in jquery: 1. hide() method, introduce the jQuery library into the HTML page, you can use different selectors to hide the select element, the ID selector replaces the selectId with the ID of the select element you actually use; 2. css() method, use the ID selector to select the select element that needs to be hidden, use the css() method to set the display attribute to none, and replace selectId with the ID of the select element.

What is the file format of db? What is the file format of db? Mar 07, 2023 pm 05:27 PM

db is a database file format, which is a file used by software to store data. It is equivalent to a database. Each software has its own storage format, that is, the way the data is arranged; the suffix of some software data files is DB. For example, Thumbs.db under Win7 system is a thumbnail data file; therefore, the db file is not a specific file format.

How to reorder multiple columns in Power Query via drag and drop How to reorder multiple columns in Power Query via drag and drop Mar 14, 2024 am 10:55 AM

In this article, we will show you how to reorder multiple columns in PowerQuery by dragging and dropping. Often, when importing data from various sources, columns may not be in the desired order. Reordering columns not only allows you to arrange them in a logical order that suits your analysis or reporting needs, it also improves the readability of your data and speeds up tasks such as filtering, sorting, and performing calculations. How to rearrange multiple columns in Excel? There are many ways to rearrange columns in Excel. You can simply select the column header and drag it to the desired location. However, this approach can become cumbersome when dealing with large tables with many columns. To rearrange columns more efficiently, you can use the enhanced query editor. Enhancing the query

See all articles