0

I have this code

 <?php
include("db.php");
$sql="select * from lead";
$result=mysqli_query($conn, $sql);
$i=0;
 ?>
 <?php while($row=mysqli_fetch_array($result)) { 
if($row['del']==1){ 
$sql1="select count(*) from notes where lead_id='$row[lead_id]'";
$var=mysqli_query($conn,$sql1);
                $var=mysqli_query($conn,$sql1);
                $var1=mysqli_num_rows($var);
?>

and below this php code is table which displays the data fetched by $row.The problem is I am not getting the correct count of rows.It shows 1 but I have multiple rows with same lead id

1
  • Nobody will stop you to use even 100 of them. Just make sure you do what you want Commented Jul 30, 2015 at 8:26

2 Answers 2

1

You call for $sql1="select count(*) from notes where lead_id='$row[lead_id]'";
and you have
$var=mysqli_query($conn,$sql1); $var1=mysqli_num_rows($var);
But that mysql_query will return only one row with count(*).
So you have to do
$sql1="select * from notes where lead_id='$row[lead_id]'";
and call
mysqli_num_rows($var);

Sign up to request clarification or add additional context in comments.

Comments

0

change

$var=mysqli_query($conn,$sql1);

to

$var = mysqli_multi_query($conn, $sql1);

1 Comment

mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean. It gives this error

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.