a Small help about php
#6

Quote:
Originally Posted by Ahmad45123
Посмотреть сообщение
I don't know if this is the best method to do it or not though, Kaperstone might help u more about it...
EDIT: completely messed up as I looked at his post and your respond.
On his post he requests to count columns, you answered how to count rows, and so I confused.


However, to count fields
PHP код:
$mysqli->query("SELECT * FROM `users` LIMIT 0")->field_count 
a bit shorter way to count rows (which is what being searched for)
PHP код:
$mysqli->query("SELECT count(*) FROM `users`")->fetch_array()[0
MySQL connection giving data to the query, query launches and return data -> data is being converted into array, index 0 in the array is being returned.

I see there is a small confusion between rows, fields and columns, so I want to clarify the difference:
Field's are the values that are being fetched
Columns are vertical rows that you can name in order to know which data to fetch out of a set.
Rows are the horizontal rows that contain the data you stored, you can add an ID and use it as an index to each row of data.

Reply


Messages In This Thread
a Small help about php - by SWAT4 - 05.12.2015, 14:37
Re: a Small help about php - by Ahmad45123 - 05.12.2015, 15:58
Re: a Small help about php - by Kaperstone - 05.12.2015, 16:23
Re: a Small help about php - by SWAT4 - 05.12.2015, 19:42
Re: a Small help about php - by Ahmad45123 - 05.12.2015, 20:00
Re: a Small help about php - by Kaperstone - 05.12.2015, 22:01
Re: a Small help about php - by Ahmad45123 - 05.12.2015, 22:10
Re: a Small help about php - by Kaperstone - 05.12.2015, 22:14
Re: a Small help about php - by Ahmad45123 - 05.12.2015, 22:37

Forum Jump:


Users browsing this thread: 3 Guest(s)