Linked Questions
12 questions linked to/from MySQLi count(*) always returns 1
0 votes
2 answers
4k views
mysqli_num_rows returns 1 no matter what [duplicate]
When I do a SQL search in phpMyAdmin (substituting the variable for the actual value) it returns the correct row number but when using PHP to return this value it always returns 1 no matter what. ...
-1 votes
1 answer
2k views
How to store COUNT(*) result in variable in mysqli [duplicate]
I'm trying to store the result of COUNT(*) in a variable and use it later for an if statement. Here is my current code: $query = mysqli_query($mysqli, "SELECT COUNT(*) FROM appointment WHERE date = '$...
2 votes
2 answers
386 views
Getting wrong number when counting rows in PHP [duplicate]
I have a table called quote in my database with 5 rows. However when I try to count the rows it always returns 1 instead of 5. I am using the code below: $connection = mysqli_connect("host","username"...
0 votes
1 answer
661 views
mysqli_num_rows() incorrect result [duplicate]
I've an empty MySQL pets table. When I use the following PHP code, it provides one(1). $query = "SELECT COUNT(*) FROM pets"; $result = mysqli_query($connect,$query); $total=mysqli_num_rows($result); ...
0 votes
2 answers
82 views
PHP MySQL not returning the correct count [duplicate]
I have verified my query using phpMyAdmin. The count is 130. But my code is giving me a count of 1. $query2 = "SELECT COUNT(*) FROM webvulns"; $result2 = mysqli_query($connection, $query2); ...
-2 votes
3 answers
289 views
Getting only 1 as row count in php [duplicate]
Is there any mistake in this code ? or my error is somewhere else . $conn = mysqli_connect("localhost","root","root","sajan") or die("Unable to connect to MySQL"); $sql_count = "SELECT count(*) ...
0 votes
0 answers
56 views
How to execute function only if MySQL table is empty? [duplicate]
I wrote a code that is meant to create tables if they are non-existent as a way for it to populate the database on the first launch. Then I came to a part where I started writing the code that is ...
-1 votes
2 answers
64 views
calculate total value instead of rows using php and mysql [duplicate]
I'm trying to calculate the total number of tokens collected instead of the number of records in the mysql db. Although I have already put the SUM function in the query but it still counts the no. of ...
1 vote
3 answers
498 views
Is there a way to use SELECT FOUND_ROWS() in php and mysqli?
I'm trying to implement a pagination system into my website and can't get past this one stubborn error. I'm not exactly sure if you can use FOUND_ROWS() in mysqli as opposed to PDO but that's what I ...
0 votes
3 answers
333 views
PHP: else condition is not working in php
I have designed a admin login page. The if condition is working but else condition is not. After putting wrong username or password it shows blank on the same page. if(isset($_POST['submit'])) { $...
0 votes
3 answers
100 views
SQL count all doesn't execute in php
if($sql = $db->query("Count (*) FROM post_items")){ echo mysqli_num_rows($sql); } what's wrong with my code? is this the correct way to echo the total of row in a table?
-3 votes
1 answer
90 views
How can I check if there is a certain value in the mySQL server database?
I have a select option form in php/html. In the selection option forms I put php like this: <option name="time" value="0900"><?php $a=$r1; echo $a;?></option> Above it I need some ...