Minimum 4 Characters or Show Nothing - PHP
Posted
by ali
on Stack Overflow
See other posts from Stack Overflow
or by ali
Published on 2010-03-16T13:57:54Z
Indexed on
2010/03/16
14:06 UTC
Read the original article
Hit count: 194
php
|character-limit
Hi, I want to show up only words with minimum 4 Characters, actually I can limit the hits and show only words with min. 100 hits - but how can I set a min. character length? thank you!
function sm_list_recent_searches($before = '', $after = '', $count = 20) {
// List the most recent successful searches.
global $wpdb, $table_prefix;
$count = intval($count);
$results = $wpdb->get_results(
"SELECT `terms`, `datetime`
FROM `{$table_prefix}searchmeter_recent`
WHERE 100 < `hits`
ORDER BY `datetime` DESC
LIMIT $count");
if (count($results)) {
foreach ($results as $result) {
echo '<a href="'. get_settings('home') . '/search/' . urlencode($result->terms) . '">'. htmlspecialchars($result->terms) .'</a>'.", ";
}
}
}
© Stack Overflow or respective owner