Answer the question
In order to leave comments, you need to log in
Why is it impossible to determine the number of results in a query to mysql in php?
Why is it impossible to determine the number of results in a query to mysql in php?
$db = mysql_connect($host,$user,$password);
mysql_select_db($basename, $db);
mysql_query("SET NAMES 'utf8'");
mysql_query("SET CHARACTER SET 'utf8'");
$result = mysql_query("SELECT * FROM keywords WHERE keyword = 'photo онлайн'");
$total = mysql_num_rows($result);
echo $total;
$result = mysql_query("SELECT * FROM keywords WHERE keyword = 'modeling websites'");
$total = mysql_num_rows($result);
echo $total;
Answer the question
In order to leave comments, you need to log in
"SELECT COUNT(*) FROM keywords WHERE keyword = 'modeling websites'"
Try this query, then you won't need num rows at all.
The database will return the number of records itself
To be honest, I'm not really eager to check your code, so I'll add: Have you tried SQL_CALC_FOUND_ROWS + FOUND_ROWS()?
And you don't need any SELECT counts. For this, just, there is FOUND_ROWS. Check out the documentation. Everything is simple.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question