kinesh18 Posted August 29, 2009 Share Posted August 29, 2009 hi everyone.i really need help on how to count a field from mysql.its my first time doing it just a little sample will help..tanx2... Link to comment https://forums.phpfreaks.com/topic/172400-really-need-help-in-counting-entered-name-in-mysql-for-php/ Share on other sites More sharing options...
thebadbad Posted August 29, 2009 Share Posted August 29, 2009 Count a field? Like .. 1? Elaborate. Link to comment https://forums.phpfreaks.com/topic/172400-really-need-help-in-counting-entered-name-in-mysql-for-php/#findComment-908960 Share on other sites More sharing options...
unknown1 Posted August 29, 2009 Share Posted August 29, 2009 Here is an example //select info from database $sql = "SELECT * FROM tableName some condition "; // error if you have a problem $resultSet = mysql_query($sql) or die (mysql_error()); // Check if info exists in database if(mysql_num_rows($resultSet) > 0) { // if selected info exists while($row = mysql_fetch_array($resultSet)) { echo "$row[fieldName]"; } Hope it helps Link to comment https://forums.phpfreaks.com/topic/172400-really-need-help-in-counting-entered-name-in-mysql-for-php/#findComment-909022 Share on other sites More sharing options...
unknown1 Posted August 29, 2009 Share Posted August 29, 2009 or you may want something like $totalCount = "SELECT COUNT(*) as 'Total' FROM tabeName"; $lCount = mysql_query($totalCount) or die(mysql_error()); $rowCount = mysql_fetch_object($lCount); Link to comment https://forums.phpfreaks.com/topic/172400-really-need-help-in-counting-entered-name-in-mysql-for-php/#findComment-909024 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.