Welcome Guest, Not a member yet? Register   Sign In
problem in finding second maximum value
#11

[eluser]Bigil Michael[/eluser]
but it shows error
Quote:A PHP Error was encountered

Severity: Notice

Message: Trying to get property of non-object

Filename: controllers/election_result.php

Line Number: 42

A PHP Error was encountered

Severity: Notice

Message: Trying to get property of non-object

Filename: controllers/election_result.php

Line Number: 43

in the model we use
Quote:if($query->num_rows() > 0)
{
$row = $query->row();

// display results
echo '<pre>';
print_r($query->row());
echo '</pre>';
}

but it willnot print anything
#12

[eluser]Bigil Michael[/eluser]
ok ok
now it prints result of the person who has maximum votes

i want 2nd maximum
#13

[eluser]John_Betong_002[/eluser]
Modify your SQL so that it returns the top maybe 5 rows (using LIMIT 0,5).

Display all the $query-result(). Ensure the data is what you want. It should be the second row-&gt;canditate_ votes.

Display your results.

&nbsp;
&nbsp;
&nbsp;
#14

[eluser]Bigil Michael[/eluser]
when the result become 0
ie if the year and constituency_id didnot matches

at that time it shows error on controller as undefined property

how will i avoid that error?????
#15

[eluser]John_Betong_002[/eluser]
[quote author="Bigil MM" date="1303310808"]
when the result become 0
ie if the year and constituency_id didnot matches

at that time it shows error on controller as undefined property

how will i avoid that error?????
[/quote]
The code I supplied had a check to prevent the undefined property error.

If you chose to remove the check then the error will always appear.
Code:
#query = $this->db->query($sql);
  if($query->num_rows() > 0)
  {
    // IT IS OK TO DO SOMETHING BECAUSE THERE IS VALID DATA
  }

&nbsp;
&nbsp;
&nbsp;
#16

[eluser]Bigil Michael[/eluser]
thank you so much
i have solved my problem
#17

[eluser]John_Betong_002[/eluser]
I am glad I was able to help.

Can you mark this post as SOLVED and supply your solution so that others may gain from your knowledge.
&nbsp;
#18

[eluser]Bigil Michael[/eluser]
how to mark it as solved




Theme © iAndrew 2016 - Forum software by © MyBB