1

I would like to display 2 rows of 5 but i can't seem to think of the logic behind. Help is appreciated.

$sql = " SELECT  KEYWORD, COUNT(*) Count_Duplicate
FROM {$_POST['btn']}
GROUP BY KEYWORD
HAVING COUNT(*) > 1
ORDER BY COUNT(*) DESC
LIMIT 10";

This is my SQL query part and i echo it like this,

echo   $row['KEYWORD'] .", " ."  "  ;
4
  • what do you mean display 2 rows of 5 ? you only have 5 rows in the db? change LIMIT 10 to LIMIT 5 ?? Commented Jan 31, 2016 at 6:37
  • The results now show 10 words because i limit it to 10. I want to break the 10 words into 2 rows of 5. Commented Jan 31, 2016 at 6:42
  • do you want them to be displayed In a table? Commented Jan 31, 2016 at 6:43
  • Yes please, a table would be more neat Commented Jan 31, 2016 at 6:44

2 Answers 2

1

try this code.

$sql = " SELECT  KEYWORD, COUNT(*) as Count_Duplicate FROM {$_POST['btn']} GROUP BY KEYWORD
HAVING COUNT(*) > 1 ORDER BY COUNT(*) DESC LIMIT 2";

use loop for display results

Sign up to request clarification or add additional context in comments.

Comments

1

You can use limit with offset value it will help you for lazy-loading also. Limit can be change in this way.

$sql = " SELECT  KEYWORD, COUNT(*) Count_Duplicate 
          FROM {$_POST['btn']} GROUP BY KEYWORD HAVING COUNT(*) > 1 
            ORDER BY COUNT(*) DESC LIMIT 2,OFFSET 10";

Offset shows the index upto which the rows will be select, and you can ignore OFFSET use limit as LIMIT 2, 10; only.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.