


Differences between PHP functions mysql_fetch_row, assoc, array, and object_PHP tutorial
The difference between PHP functions mysql_fetch_row, assoc, array and object
1. mysql_fetch_row
This function takes a row from the result set as enumeration data, obtains a row of data from the result set associated with the specified result identifier, and returns it as an array. Each result column is stored in a cell of the array, starting at offset 0.
Note that the offset here starts from 0, which means that the field name cannot be used to obtain the value, only the index can be used to obtain the value. For example:
while($row = mysql_fetch_row($res)){
echo $row['cid'].'>>>'.$row[1].'
';
}
The value of $row['cid'] here cannot be obtained, but $row[1] can.
2. mysql_fetch_assoc
Get a row from the result set as an associative array, which means that this function cannot use the index to get the value like mysql_fetch_row, but can only use the field name to get the value. For example:
while($row = mysql_fetch_assoc($res)){
echo $row['cid'].'>>>'.$row[1].'
';
}
Here $row[1] cannot get the value, but $row['cid'] can.
3. mysql_fetch_array
Get a row from the result set as an associative array, or a numeric array, or both. In addition to storing the data in the array as a numeric index, you can also store the data as an associative index, using the field name as the key. name.
That is to say, the result he gets is like an array, and the value can be obtained by key or index. For example:
while($row = mysql_fetch_array($res)){
echo $row['cid'].'>>>'.$row[1].'
';
}
Here $row['cid'] and $row[1] can get corresponding values.
The functions of mysql_fetch_row and mysql_fetch_assoc add up to mysql_fetch_array.
4. mysql_fetch_object
As the name suggests, get a row from the result set as an object and use the field name as an attribute. So the only way to get the value is:
while($row = mysql_fetch_object($res)){
echo $row->cid.'>>>'.$row->title."
";
}

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

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

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

Hot Topics

MySQL and phpMyAdmin are powerful database management tools. 1) MySQL is used to create databases and tables, and to execute DML and SQL queries. 2) phpMyAdmin provides an intuitive interface for database management, table structure management, data operations and user permission management.

Safely handle functions and regular expressions in JSON In front-end development, JavaScript is often required...

IIS and PHP are compatible and are implemented through FastCGI. 1.IIS forwards the .php file request to the FastCGI module through the configuration file. 2. The FastCGI module starts the PHP process to process requests to improve performance and stability. 3. In actual applications, you need to pay attention to configuration details, error debugging and performance optimization.

In MySQL, the function of foreign keys is to establish the relationship between tables and ensure the consistency and integrity of the data. Foreign keys maintain the effectiveness of data through reference integrity checks and cascading operations. Pay attention to performance optimization and avoid common errors when using them.

MySQL is suitable for rapid development and small and medium-sized applications, while Oracle is suitable for large enterprises and high availability needs. 1) MySQL is open source and easy to use, suitable for web applications and small and medium-sized enterprises. 2) Oracle is powerful and suitable for large enterprises and government agencies. 3) MySQL supports a variety of storage engines, and Oracle provides rich enterprise-level functions.

Effective method of querying personnel data through natural language processing How to efficiently use natural language processing (NLP) technology when processing large amounts of personnel data...

The difference between decentralized exchanges and hybrid exchanges is mainly reflected in: 1. Trading mechanism: Decentralized exchanges use smart contracts to match transactions, while hybrid exchanges combine centralized and decentralized mechanisms. 2. Asset control: Decentralized exchange users control assets, and mixed exchange ownership centralization and decentralization. 3. Privacy protection: Decentralized exchanges provide high anonymity, and hybrid exchanges require KYC in centralized mode. 4. Trading speed and liquidity: Decentralized exchanges are slower, liquidity depends on user pool, and hybrid exchanges are more fast and liquid in centralized mode. 5. Platform governance: Decentralized exchanges are governed by community governance, and hybrid exchanges are jointly governed by communities and centralized teams.

SQL is a standard language for managing relational databases, while MySQL is a database management system that uses SQL. SQL defines ways to interact with a database, including CRUD operations, while MySQL implements the SQL standard and provides additional features such as stored procedures and triggers.
