Questions tagged [mysql-num-rows]

Retrieves the number of rows from a result set.

mysql_num_rows($resultSet) is used to retrieve the number of rows in $resultSet.

It should only be used on a result set generated from a query that produces an actual set of results, such as SELECT. If you want to get the number of rows affected by an UPDATE, DELETE, or INSERT, you should use mysql_affected_rows instead.

It will return the number of rows in the rowset; or boolean FALSE on failure.

Note that as of PHP 5.5.0, this function has been deprecated.

181 questions
1
vote
1 answer

Fetch query from Magento database -- mysql_num_rows

What function is equal to mysql_num_rows in Magento?
Alireza Seifi
  • 50
  • 1
  • 8
1
vote
3 answers

Counting rows in mysql database

I want to count from the row with the least value to the row with a specific value. For example, Name / Point -------------------- Pikachu / 7 Voltorb / 1 Abra / 4 Sunflora / 3 Squirtle / 8 Snorlax / 12 I want to count to the 7, so I get the…
gyogyo0101
  • 61
  • 1
  • 2
  • 10
1
vote
5 answers

mysql left join returns unexpected amount of rows

I have 2 tables where tableA has 41 rows and tableB has 3 rows I am trying to get the total rows of these 2 tables via a query using left join but i get way more rows(123) than expected(44) query: SELECT COUNT(*) FROM tableA as u LEFT JOIN…
stergosz
  • 5,754
  • 13
  • 62
  • 133
1
vote
3 answers

How to count the most common value in SQL?

At the moment I've got the following code: $forummost = mysql_query(" SELECT door, COUNT(door) AS doorCount FROM forum_posts GROUP BY door ORDER BY COUNT(door) DESC "); $forummostc = mysql_num_rows($forummost); $forummostf =…
Mossawi
  • 871
  • 2
  • 10
  • 17
0
votes
2 answers

mysql_num_rows PHP

elseif(isset($_POST['submit'])) { // Look for their user $lookuser = mysql_query("SELECT * FROM `users` WHERE username='". mysql_escape_string($_POST['username']) ."'"); // If we find a row if(mysql_num_rows($lookuser) > 0) But my…
Nathan
  • 534
  • 1
  • 5
  • 13
0
votes
1 answer

MySQL difference of two rows between two with PHP mysql_num_rows function?

Is it possible to somehow calc the difference between two rows of one table? I tried this, but it doesnt work: $diff = mysql_num_rows(" SELECT (`used`-`paid`) FROM `coupons_codes` WHERE `cid`='".$data['cid']."'");
Vay
  • 117
  • 2
  • 14
0
votes
1 answer

How to echo "no results" message when no search results are found in MYSQL?

I have a mysql keyword search on my website and it works fine. The problem is when someone searches a keyword I haven't added, nothing shows up on the results page. Instead of nothing showing up I would like to have a no results were found message.…
Will
  • 33
  • 2
  • 8
0
votes
4 answers

PHP / MYSQL error: mysql_num_rows(): supplied argument is not a valid

I have the following code: $sql = mysql_query("SELECT id FROM logins WHERE id='" . $this->skID . "'"); if(mysql_num_rows($sql) == 0) { return false; } else { list($skID) = mysql_fetch_row($sql); return $skID; } which brings back…
LeeTee
  • 6,401
  • 16
  • 79
  • 139
0
votes
3 answers

Mysql error when counting rows

I have a problem when trying to count the rows in a table. The variable $username_me equals to the session username. None of them is in an if or else statement. The error i get is: Warning: mysql_num_rows() expects parameter 1 to be resource,…
Kaizokupuffball
  • 2,703
  • 8
  • 38
  • 58
0
votes
3 answers

PHP mysql_num_rows() Returns error

I have a PHP login script. This is the part where the person can create a new user. My issue is I want to check if the user exists, and if the username does not exist the the table, than create the new user. However, if the user does exist, I want…
comu
  • 921
  • 1
  • 11
  • 29
0
votes
1 answer

Select-Option num value vs SQL num_row

I have a big dilemma, I'm generating data from MySQL into a form so, the problem is that while the first row generated by SQL is 0 the select option in the form is interpreting the first value as 1. Would not be any problem if I wouldn't wanted to…
sealview
  • 99
  • 1
  • 8
0
votes
2 answers

MySQL number rows error

$result = mysql_query("SELECT FROM table WHERE job_id = '$key'") or die("Error: ". mysql_error(). " with query ". $query); $num_rows = mysql_num_rows($result); if($num_rows > 0) { mysql_query("UPDATE table SET row = '$value' WHERE…
Chris
  • 374
  • 1
  • 5
  • 16
0
votes
3 answers

error on mysql_num_rows

my code is following iam getting a error on "Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource..." help me to solve this
nala
  • 1
0
votes
4 answers

mysql_num_rows() Error

virusbogdan
  • 187
  • 1
  • 3
  • 13