1

So far I have the code that gives me array(1) { [0]=> object(stdClass)#166 (1) { ["id"]=> string(2) "92" }} the following result but what do I have to do to enable me to use it via mysqli_num_rows?

Code:

$query = $this->db->query("SELECT `id` FROM $table WHERE $table.id ='$product_id'");

        $result = $query->result();

3 Answers 3

2

Try with affected_rows() like

$query = $this->db->query("SELECT `id` FROM $table WHERE $table.id ='$product_id'");
$result = $query->result();

$row_cnt = $this->db->affected_rows();
Sign up to request clarification or add additional context in comments.

2 Comments

I am still getting ` mysqli_num_rows() expects parameter 1 to be mysqli_result, array given`
previously i have given ans with mysqli_num_rows,but now given with affecte_rows()
1

when doing SELECT you must use num_rows()

when doing UPDATE,INSERT,DELETE use affected_rows()

Comments

0

The row count can be found with:

echo $query->num_rows;

Reference

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.