L
L
Luka Tarkhnishvili2016-09-13 15:25:56
PHP
Luka Tarkhnishvili, 2016-09-13 15:25:56

How to display the number of found materials?

How to display the number of found materials on the site? I use num_rows but it only displays how many on one page and not the number of all found materials. what do you advise?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Victor Pleisun, 2016-09-13
@Zorner

<?php 
$Query = mysqli_query($CONNECT, "SELECT `id`, `title`, `himg`, `readed` FROM `news` WHERE `content` LIKE '%{$keywords}%' OR `title` LIKE '%{$keywords}%');
?> 
найдено <?php echo $Query->num_rows; ?>

That is, you need another request and just remove LIMIT and OFFSET from it

N
nonameguy, 2016-09-13
@nonameguy

$r = mysql_query( "SELECT count(*) FROM ...." );
$count = mysql_result( $r, 0, 0 );

U
uaking, 2016-09-13
@uaking

You can use the SQL_CALC_FOUND_ROWS option to SELECT
Find Materials
SELECT SQL_CALC_FOUND_ROWS * FROM tbl_name WHERE id > 100 LIMIT 10;
Number of records
SELECT FOUND_ROWS();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question