PHP count number of rows in SELECT with WHERE clause in mysql -
i have table 2 columns 'community' , 'status' in following format:
community status zoo 1 zoo 1 zoo 0 zoo 1
now want count how many rows status=1 there zoo; above example want output "no of rows 3"
for now, can query rows status 1 zoo column , echo result output 111.
the code snippet below:
if (mysqli_connect_errno()) { printf("connect failed: %s\n", mysqli_connect_error()); exit(); } $query = "select * location (community = 'zoo') , (status = '1');"; $result = $mysqli->query($query); while($row = $result->fetch_array()) { $rows[] = $row; } foreach($rows $row) { echo $row['status']; } $result->close();
can please show me or implement mysql_num_rows here?
just use mysqli_num_rows(); function
$q="select * location community='zoo' , status='1'"; $res=mysqli_query($con,$q); echo mysqli_num_rows($res);
Comments
Post a Comment