简体   繁体   中英

how to display all row data of mysql field name

I am trying to display all the data of mysql field but having issue display it. What I want to do is display all the first name and last name of the members which has a membership level of 1 so if there are 20 users with membership level 1, it would display 20 first name

$query = "SELECT first_name, last_name FROM " . $wpdb->prefix . "ss_table WHERE membership_level = 1";
echo $query[20];

Your sql query is wrong, you should first check out sql sites for writing query
For fetching a single column from a table you have to use

select first_name from ss_table

but for fetching more than one column you have to append "," after every column name except after the last column

select first_name, last_name from ss_table

You've written a query, but you need to execute it if you want to get results. Echoing $query[20] will just give you the 20th character of your query statement. Look into some docs: http://php.net/manual/en/book.mysqli.php or tutorials on how to connect to a database.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM