I'm getting the following error before performing employee search
up vote
0
down vote
favorite

When i load my controller i'm getting this error in my homepage, but after performing search the error will disappear and search results will be displayed there.
This is my view page:
<div id="toggle_tst">
<div class="scroll">
<?php
// List up all results.
echo "<table id='table'>";
echo "<tbody>";
echo "<thead>";
echo "<tr><th>NAME</th><th>Pernor No</th><th>DESIGNATION ID</th>
</tr>";
echo "</thead>";
foreach ($results as $row)
{
echo "<tr><td>";
echo $row['name'];
echo "</td><td>";
echo $row['pernor_no'];
echo "</td><td>";
echo $row['designation_id'];
echo "</td></tr>";
}
if (isset($_POST['data_rows']))
{
//if the page has been submitted, append the rows
echo $_POST['data_rows'];
}
echo "</tbody>";
echo "</table>";
?>
</div>
</div>
Controller:
public function execute_search()
{
// Retrieve the posted search term.
$search_term = $this->input->post('search');
$data['query'] = $this->JcMeetingExpense_model->viewother();
$data['query1'] = $this->JcMeetingExpense_model->viewcatprice();
// Use a model to retrieve the results.
$data['results'] = $this->JcMeetingExpense_model-
>get_results($search_term);
// Pass the results to the view.
$this->load->view('JcMeetingExpense/jc_meeting_expense',$data);
}
php mysql codeigniter
add a comment |
up vote
0
down vote
favorite

When i load my controller i'm getting this error in my homepage, but after performing search the error will disappear and search results will be displayed there.
This is my view page:
<div id="toggle_tst">
<div class="scroll">
<?php
// List up all results.
echo "<table id='table'>";
echo "<tbody>";
echo "<thead>";
echo "<tr><th>NAME</th><th>Pernor No</th><th>DESIGNATION ID</th>
</tr>";
echo "</thead>";
foreach ($results as $row)
{
echo "<tr><td>";
echo $row['name'];
echo "</td><td>";
echo $row['pernor_no'];
echo "</td><td>";
echo $row['designation_id'];
echo "</td></tr>";
}
if (isset($_POST['data_rows']))
{
//if the page has been submitted, append the rows
echo $_POST['data_rows'];
}
echo "</tbody>";
echo "</table>";
?>
</div>
</div>
Controller:
public function execute_search()
{
// Retrieve the posted search term.
$search_term = $this->input->post('search');
$data['query'] = $this->JcMeetingExpense_model->viewother();
$data['query1'] = $this->JcMeetingExpense_model->viewcatprice();
// Use a model to retrieve the results.
$data['results'] = $this->JcMeetingExpense_model-
>get_results($search_term);
// Pass the results to the view.
$this->load->view('JcMeetingExpense/jc_meeting_expense',$data);
}
php mysql codeigniter
$results is not returning array so you are getting error. are you able to get results from controller?
– Jasmin Mistry
Aug 30 at 5:57
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite

When i load my controller i'm getting this error in my homepage, but after performing search the error will disappear and search results will be displayed there.
This is my view page:
<div id="toggle_tst">
<div class="scroll">
<?php
// List up all results.
echo "<table id='table'>";
echo "<tbody>";
echo "<thead>";
echo "<tr><th>NAME</th><th>Pernor No</th><th>DESIGNATION ID</th>
</tr>";
echo "</thead>";
foreach ($results as $row)
{
echo "<tr><td>";
echo $row['name'];
echo "</td><td>";
echo $row['pernor_no'];
echo "</td><td>";
echo $row['designation_id'];
echo "</td></tr>";
}
if (isset($_POST['data_rows']))
{
//if the page has been submitted, append the rows
echo $_POST['data_rows'];
}
echo "</tbody>";
echo "</table>";
?>
</div>
</div>
Controller:
public function execute_search()
{
// Retrieve the posted search term.
$search_term = $this->input->post('search');
$data['query'] = $this->JcMeetingExpense_model->viewother();
$data['query1'] = $this->JcMeetingExpense_model->viewcatprice();
// Use a model to retrieve the results.
$data['results'] = $this->JcMeetingExpense_model-
>get_results($search_term);
// Pass the results to the view.
$this->load->view('JcMeetingExpense/jc_meeting_expense',$data);
}
php mysql codeigniter

When i load my controller i'm getting this error in my homepage, but after performing search the error will disappear and search results will be displayed there.
This is my view page:
<div id="toggle_tst">
<div class="scroll">
<?php
// List up all results.
echo "<table id='table'>";
echo "<tbody>";
echo "<thead>";
echo "<tr><th>NAME</th><th>Pernor No</th><th>DESIGNATION ID</th>
</tr>";
echo "</thead>";
foreach ($results as $row)
{
echo "<tr><td>";
echo $row['name'];
echo "</td><td>";
echo $row['pernor_no'];
echo "</td><td>";
echo $row['designation_id'];
echo "</td></tr>";
}
if (isset($_POST['data_rows']))
{
//if the page has been submitted, append the rows
echo $_POST['data_rows'];
}
echo "</tbody>";
echo "</table>";
?>
</div>
</div>
Controller:
public function execute_search()
{
// Retrieve the posted search term.
$search_term = $this->input->post('search');
$data['query'] = $this->JcMeetingExpense_model->viewother();
$data['query1'] = $this->JcMeetingExpense_model->viewcatprice();
// Use a model to retrieve the results.
$data['results'] = $this->JcMeetingExpense_model-
>get_results($search_term);
// Pass the results to the view.
$this->load->view('JcMeetingExpense/jc_meeting_expense',$data);
}
php mysql codeigniter
php mysql codeigniter
edited Aug 30 at 5:55
ochs.tobi
1,25061029
1,25061029
asked Aug 30 at 5:30
Srujan Ramanna Gowda
15
15
$results is not returning array so you are getting error. are you able to get results from controller?
– Jasmin Mistry
Aug 30 at 5:57
add a comment |
$results is not returning array so you are getting error. are you able to get results from controller?
– Jasmin Mistry
Aug 30 at 5:57
$results is not returning array so you are getting error. are you able to get results from controller?
– Jasmin Mistry
Aug 30 at 5:57
$results is not returning array so you are getting error. are you able to get results from controller?
– Jasmin Mistry
Aug 30 at 5:57
add a comment |
3 Answers
3
active
oldest
votes
up vote
3
down vote
use isset before going to execute loop.
isset is the best practice if you are using in your code for variables and array.
For your solution : use below code
if(isset($results)){
// all code inside it...
}
add a comment |
up vote
3
down vote
always use isset() for kind of same condition.
For more details : Click Here!
use below code
if(isset($results)){
// all code inside it...
}
add a comment |
up vote
1
down vote
The reason is you haven't set the variable results. So simple solution is to add a isset() before foreach loop.
if(isset($results)){
foreach ($results as $row){
.
.
.
.
}
}
Hey tat's worked.... thank you so much!!!
– Srujan Ramanna Gowda
Aug 30 at 6:20
you're welcome ;-)
– kalanamw
Aug 31 at 9:13
add a comment |
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
use isset before going to execute loop.
isset is the best practice if you are using in your code for variables and array.
For your solution : use below code
if(isset($results)){
// all code inside it...
}
add a comment |
up vote
3
down vote
use isset before going to execute loop.
isset is the best practice if you are using in your code for variables and array.
For your solution : use below code
if(isset($results)){
// all code inside it...
}
add a comment |
up vote
3
down vote
up vote
3
down vote
use isset before going to execute loop.
isset is the best practice if you are using in your code for variables and array.
For your solution : use below code
if(isset($results)){
// all code inside it...
}
use isset before going to execute loop.
isset is the best practice if you are using in your code for variables and array.
For your solution : use below code
if(isset($results)){
// all code inside it...
}
answered Nov 21 at 11:11
Coolbuddy
23216
23216
add a comment |
add a comment |
up vote
3
down vote
always use isset() for kind of same condition.
For more details : Click Here!
use below code
if(isset($results)){
// all code inside it...
}
add a comment |
up vote
3
down vote
always use isset() for kind of same condition.
For more details : Click Here!
use below code
if(isset($results)){
// all code inside it...
}
add a comment |
up vote
3
down vote
up vote
3
down vote
always use isset() for kind of same condition.
For more details : Click Here!
use below code
if(isset($results)){
// all code inside it...
}
always use isset() for kind of same condition.
For more details : Click Here!
use below code
if(isset($results)){
// all code inside it...
}
answered Nov 21 at 11:18
vishal melwani
1545
1545
add a comment |
add a comment |
up vote
1
down vote
The reason is you haven't set the variable results. So simple solution is to add a isset() before foreach loop.
if(isset($results)){
foreach ($results as $row){
.
.
.
.
}
}
Hey tat's worked.... thank you so much!!!
– Srujan Ramanna Gowda
Aug 30 at 6:20
you're welcome ;-)
– kalanamw
Aug 31 at 9:13
add a comment |
up vote
1
down vote
The reason is you haven't set the variable results. So simple solution is to add a isset() before foreach loop.
if(isset($results)){
foreach ($results as $row){
.
.
.
.
}
}
Hey tat's worked.... thank you so much!!!
– Srujan Ramanna Gowda
Aug 30 at 6:20
you're welcome ;-)
– kalanamw
Aug 31 at 9:13
add a comment |
up vote
1
down vote
up vote
1
down vote
The reason is you haven't set the variable results. So simple solution is to add a isset() before foreach loop.
if(isset($results)){
foreach ($results as $row){
.
.
.
.
}
}
The reason is you haven't set the variable results. So simple solution is to add a isset() before foreach loop.
if(isset($results)){
foreach ($results as $row){
.
.
.
.
}
}
edited Aug 30 at 7:10
Erubiel
1,790318
1,790318
answered Aug 30 at 6:04
kalanamw
134
134
Hey tat's worked.... thank you so much!!!
– Srujan Ramanna Gowda
Aug 30 at 6:20
you're welcome ;-)
– kalanamw
Aug 31 at 9:13
add a comment |
Hey tat's worked.... thank you so much!!!
– Srujan Ramanna Gowda
Aug 30 at 6:20
you're welcome ;-)
– kalanamw
Aug 31 at 9:13
Hey tat's worked.... thank you so much!!!
– Srujan Ramanna Gowda
Aug 30 at 6:20
Hey tat's worked.... thank you so much!!!
– Srujan Ramanna Gowda
Aug 30 at 6:20
you're welcome ;-)
– kalanamw
Aug 31 at 9:13
you're welcome ;-)
– kalanamw
Aug 31 at 9:13
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f52089772%2fim-getting-the-following-error-before-performing-employee-search%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
$results is not returning array so you are getting error. are you able to get results from controller?
– Jasmin Mistry
Aug 30 at 5:57