Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to query mysql php one-dimensional array

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

Today, I will talk to you about how to query the one-dimensional array of mysql php. Many people may not know much about it. In order to make you understand better, the editor has summarized the following contents for you. I hope you can get something according to this article.

Mysql php query one-dimensional array method: 1, through the "mysql_connect" function to connect to the database; 2, through the "mysql_query" query; 3, the use of "mysql_fetch_assoc" function to return the array.

This article operating environment: Windows7 system, PHP7.1, Dell G3 computer.

How does mysql php query one-dimensional arrays?

Specific problem description:

How does PHP fetch an one-dimensional array from the database

Just want to take out the name of the game and change it to an one-dimensional array of $con = mysql_connect ('localhost',' root', 'root'); mysql_select_db ("php", $con); $result = mysql_query ("SELECT * FROM `game`"); $data_name [] = array (); while ($rs = mysql_fetch_assoc ($result)) {$data_name [] = $rs [' name']; / this is a two-dimensional array} = this is a two-dimensional array. Array ([0] = > Array () [1] = > League of Legends [2] = > DNF [3] = > Longzhigu) how to take one dimension?

Solution:

The code is as follows:

$con = mysql_connect ('localhost',' root', 'root'); mysql_select_db ("php", $con); $result = mysql_query ("SELECT * FROM `game`"); $data_name=array (); / / modified while ($rs = mysql_fetch_assoc ($result)) {$data_name [] = $rs [' name'];} print_r ($data_name) / / after reading the above content, do you have any further understanding of how to query the mysql php one-dimensional array? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report