me1000 Posted July 11, 2007 Share Posted July 11, 2007 Previous Page Next Page Is there a PHP function that counts the number of time something appears in a MySQL query? So I run the query, and it finds the number of times " " is found in the returned results. Previous Page Next Page Link to comment https://forums.phpfreaks.com/topic/59486-solved-count-the-instances/ Share on other sites More sharing options...
marcus Posted July 11, 2007 Share Posted July 11, 2007 Previous Page Next Page Something like: $sql = "SELECT * FROM `tbl_name` WHERE `field_name` LIKE '% %'"; $res = mysql_query($sql) or die(mysql_error()); echo mysql_num_rows($res); ?? Previous Page Next Page Link to comment https://forums.phpfreaks.com/topic/59486-solved-count-the-instances/#findComment-295620 Share on other sites More sharing options...
me1000 Posted July 11, 2007 Author Share Posted July 11, 2007 Previous Page Next Page That gives me back the number of entries with ' ' in it. I just need to find the number of times ' ' is found within one entry Previous Page Next Page Link to comment https://forums.phpfreaks.com/topic/59486-solved-count-the-instances/#findComment-295638 Share on other sites More sharing options...
me1000 Posted July 11, 2007 Author Share Posted July 11, 2007 Previous Page Next Page ok I think i have it, $pages = explode(" ", $info); foreach ($pages as $v) { $i++; } echo $i-1; Previous Page Next Page Link to comment https://forums.phpfreaks.com/topic/59486-solved-count-the-instances/#findComment-295671 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.