count the no rows
instead of this total code
use mysqli_num_rows($result); command
CREATE TABLE IF NOT EXISTS `birthday` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(100) NOT NULL, `gender` varchar(100) NOT NULL, ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=0 ;
<?php /* Database config */ $db_host = 'localhost'; $db_user = 'root'; $db_pass = ''; $db_database = 'tutorial'; /* End config */ $db = new PDO('mysql:host='.$db_host.';dbname='.$db_database, $db_user, $db_pass); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); ?>
<?php include('connect.php'); $sql = $db->prepare("SELECT count(*) FROM birthday"); $sql->execute(); $rows = $sql->fetch(PDO::FETCH_NUM); $numberofrows=$rows[0]; echo 'Result : '.$numberofrows; ?>