php refreshing only data in page - php

i'm a php nearby. I have a problem with my form. I connect the controller with db and extract a question and his three answers. If i click on one of this, the system return the second question, under the first question. If i click on one of the seconds answers, the system return the thirth question overwrite the second question.
I would like that second question (and its answers) overwrite the first (and its answers). How i can?
db structure
view
1) index.php
<?php
error_reporting(E_ERROR | E_PARSE);
require_once 'controllers/controller.php';
$controllers = new Controller();
$controllers->cercaDomanda(1);
$controllers->cercaRisposta(1);
$controllers->cercaNuovoId($id);
?>
2) Controller.php
<?php
require_once('models/Domanda.php');
require_once('models/Risposta.php');
require_once ('models/Model.php');
class Controller {
public $domanda;
public $risposta;
public $model;
public function __construct(){
$this->domande = new Domanda(); //istanziamo la classe domanda
$this->risposte = new Risposta(); //istanziamo la classe risposta
$this->model = new Model(); //istanziamo la classe risposta
}
public function cercaDomanda($id){
$reslt = $this->domande->getDomanda($id);
include 'views/basicView.php';
}
public function cercaRisposta($id){
$reslt2 = $this->risposte->getRisposta($id);
include 'views/basicView.php';
}
public function cercaNuovoId($id){
include 'views/basicView.php';
$reslt3 = $this->model->getIdNext();
$reslt4 = $this->cercaDomanda($reslt3);
$reslt5 = $this->cercaRisposta($reslt3);
}
}
?>
3)Domanda.php
<?php
require_once 'models/Domanda.php';
class Domanda {
public function getDomanda($id){
$dbconnection = pg_connect("host=***port=***dbname=***user=***password=***");
$query = 'SELECT domanda FROM public."Domande" WHERE "id"='.$id;
$result = pg_query($query);
return $result;
pg_close($dbconnection);
}
}
?>
4)Risposta.php
<?php
require_once 'models/Risposta.php';
class Risposta {
public function getRisposta($id){
$dbconnection = pg_connect("host=***port=***dbname=***user=***password=***");
$query = 'SELECT * FROM public."Risposte" WHERE "id_domanda"='.$id;
$result = pg_query($query); //or die ('Query fallita: ' .pg_last_error());
return $result;
pg_close($dbconnection);
}
}
?>
5)Model.php
<?php
require_once 'models/Model.php';
class Model {
public function getIdNext(){
if(isset($_POST['btnScelta'])){
$result = $_POST['btnScelta'];
return $result;
}
}
}
6)View
<html>
<head></head>
<body>
<form action='index.php' name='chatbotyForm' method="POST">
<table>
<?php
echo "<tr>";
$domanda = pg_fetch_array($reslt, null, PGSQL_ASSOC);
print $domanda['domanda'];
echo "</tr>";
?>
</table>
<?php
while ($rispost = pg_fetch_object($reslt2)) {
print "<td><button type='submit' name='btnScelta'
value='$rispost->id_domanda_successiva'>$rispost->risposta</button>
</td>";
}
?>
</form>
</body>
</html>

In your view:
...
<?php
while ($rispost = pg_fetch_object($reslt2)) {
print "<td><button type='submit' name='btnScelta'
value='$rispost->id_domanda_successiva'>$rispost->risposta</button>
</td>";
}
?>
you are setting only one value in each button. which is available as $_POST['btnScelta'] and that is used to render your last question.
Edit previous contents removed because they are not relevant to the question.
To render two questions pass two ids as the button value.
To remove the first question remove the two lines from your index.php
1) index.php
<?php
error_reporting(E_ERROR | E_PARSE);
require_once 'controllers/controller.php';
$controllers = new Controller();
/* remove the following two lines the first question wont be rendered.*/
//$controllers->cercaDomanda(1);
//$controllers->cercaRisposta(1);
$controllers->cercaNuovoId(/*$id*/);
?>
Now make controller process two question display.
class Controller {
public function cercaNuovoId(/*$id*/){
// include 'views/basicView.php';
$reslt3 = $this->model->getIdNext();
// render previous question only if a value exists.
if ($result3) {
list($current, $previous) = explode(',', $result3);
$this->cercaDomanda($previous);
$this->cercaRisposta($previous);
}
// show the first question on first visit.
if (empty($current)){
$current = 1;
}
$reslt4 = $this->cercaDomanda($current);
$reslt5 = $this->cercaRisposta($current);
}
}
Now in the view make modification for button to have two values seperated by comma. current question id is available as $id from Controller::cercaRisposta()
<?php
while ($rispost = pg_fetch_object($reslt2)) {
print "<td><button type='submit' name='btnScelta'
value='{$rispost->id_domanda_successiva},{id}'>$rispost->risposta</button>
</td>";
}
?>
</form>
you can also pass the previous question id by changing form's action property with a query like index.php?previous=$id.

Related

Display an array data from two tables in codeigniter

I've two tables on my database, monitor [pk = idMonitor] and monitor_data [pk = idMonitor_data].
Please click you can see the tables fields here. As you can see i put the array data in table monitor_data.
I want to Update the condition for every idinventory where monitor_data.idMonitor = $id.
But first i want to display the current data of 'monitordate','idinventory', and 'condition' from database to my view.
My controller
public function edit($id=0) {
$dataa = $this->monitor_m->get_record(array('monitor_data.idMonitor'=>$id),true);
$this->data->monitordate = $dataa->monitordate;
$this->data->condition = $dataa->condition; <-line 20
$this->data->detail = $this->monitor_m->get_record(array('monitor_data.idMonitor'=>$id),true);
$this->template->set_title('SMIB | Monitoring')
->render('monitor_edit',$this->data);
}
My View (monitor_edit)
<?php echo form_open(site_url("monitor/ubah"),'data-ajax="false"'); ?>
<?php foreach ($detail as $items): ?>
<h4><?php echo '[ '.$items['idinventory'].' ] '?> </h4>
<?php echo form_label ('Condition : ');
echo form_dropdown('condition', array('good'=>'Good','broke'=>'Broken','lost'=>'Lost'),#$items['condition']);
?>
<?php endforeach; ?>
<?php echo form_close(); ?>
My Model
class Monitor_m extends MY_Model {
public function __construct(){
parent::__construct();
parent::set_table('monitor','idMonitor');
}
public function get_record($id = 0,$get_user = FALSE) {
$this->db->where($id);
if ($get_user){
$this->db->join('monitor_data','monitor_data.idMonitor = monitor.idMonitor');
$this->db->join('inventory','inventory.idinventory = monitor_data.idinventory');
$this->db->join('user','user.id_user = monitor.id_user');
}
$data = parent::get_array();
return $this->improve_data($data);
}
Here is my problem : its work fine for monitordate code in my controller, BUT i keep getting an error for condition code
Maybe because i use 'monitor_data.idMonitor' as my parameter $id not idinventory. how can i use 2 parameters for example like where idMonitor=$id and idinventory=$idiventory.
Do i explain it right ?
Severity: Notice Message: Trying to get property of non-object
Filename: controllers/monitor.php Line Number: 20
Please Please help me, i dont know what is wrong with my controller :( i've searching the solution but none of those work. :(
It's weird if you can get monitordate but can't get condition.
Can you edit your controller to be like this?
public function get_record($id = 0,$get_user = FALSE) {
$this->db->where($id);
if ($get_user){
$this->db->join('monitor_data','monitor_data.idMonitor = monitor.idMonitor');
$this->db->join('inventory','inventory.idinventory = monitor_data.idinventory');
$this->db->join('user','user.id_user = monitor.id_user');
}
// $data = parent::get_array();
$data = $this->db->result_array();
print_r($data);
echo $this->db->last_query();
exit;
return $this->improve_data($data);
}

how do i get the data from view in codeigniter

I'm not good in codeigniter i'm still learning this. So i need your help guys.
I want to get the data from the database that the id is equal to the value of the dropdown list button.so heres is my code.
This is my controller: controller.php
function getdataload(){
$this->load->view('data',$data);
}
I really don't know what to put in the controller.
This is my view: view.php
<html>
<body>
<label for="member">Member</label>
<select class="form-control" id="member" name="member" required onchange="showCustomer(this.value)">
<option selected="" value="">--select--</option>
<?php foreach ($members as $row): ?>
<option value="<?php echo $row->mem_id; ?>"><?php echo ucwords($row->mem_fname.' '.$row->mem_lname) ?></option>
<?php endforeach ?>
</select>
</body>
</html>
<script>
$('#member').on('change',function(){
$.post('<?php echo base_url("transactions/getdataload")?>',
{
mem_id:$(this).val()
}).done(function(res)
{
$('#select_member').text(res);
});
});
</script>
This is the other view that the called from the controller data.php
<?php
$q = intval($_GET['member']);
$con = mysqli_connect('localhost','root','','global89_point');
if (!$con) {
die('Could not connect: ' . mysqli_error($con));
}
mysqli_select_db($con,"global89_point");
$sql="SELECT * FROM loading_service WHERE member='".$q."'";
$result = mysqli_query($con,$sql);
echo "<table>";
echo "<tr>";
echo " <th>";
echo "Member ID";
echo "</th>";
echo "</tr>";
while($row = mysqli_fetch_array($result)) {
echo "<tr>";
echo "<td>" . $row['member'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysqli_close($con);
?>
please help me with this guys.
You should call database lib from controller if you do not use models and database logic write to controller see this:
public function result()
{
$this->load->library('database')
$data = array();
$service_list = $this->db->query("SELECT * FROM loading_service WHERE member='".$q."'")->result_array();
$data['service'] = $service_list;
$this->load->view('result', $data);
}
Here result view you get $service array and you can easily iterate this.
Our model in CodeIgniter will be placed in application/models/form_model.php
<?php
class Form_model extends Model {
function Formmodel() {
// load the parent constructor
parent::Model();
}
function submit_posted_data() {
// db is initialized in the controller, to interact with the database.
$this->db->insert('loading_service ',$_POST);
}
function get_all_data() {
// again, we use the db to get the data from table ‘form’
$data['result']=$this->db->get('loading_service');
return $data['result'];
}
}
?>
controller
ss Form extends Controller {
function Form(){
// load Controller constructor
parent::Controller();
// load the model we will be using
$this->load->model('form_model');
// load the database and connect to MySQL
$this->load->database();
// load the needed helpers
$this->load->helper(array('loading_service','url'));
}
//Display the posted entries
function index() {
$data['member']='Form Data';
//use the model to get all entries
$data['result'] = $this->form_model->get_all_data();
// load 'forms_view' view
$this->load->view('forms_view',$data);
}
//Process the posted loading_service
function submit() {
//use the model to submit the posted data
$this->form_model->submit_posted_data();
redirect('loading_service');
}
}
?>
you can refer this code..It will helpful for u...

Catching the returned value

this may be a stupid question, but every source on the web seems not able to fully explain the logic to my complex brain
There's an edit page getting a $_GET['id'] from a link.
I got a function on my class elaborating this one to create an array of values from the database which must fill the form fields to edit datas. The short part of this code:
public function prel() {
$this->id= $_GET['id'];
}
public function EditDb () {
$connetti = new connessionedb();
$dbc = $connetti->Connessione();
$query = "SELECT * from anammi.anagrafica WHERE id = '$this->id'";
$mysqli = mysqli_query($dbc, $query);
if ($mysqli) {
$fetch = mysqli_fetch_assoc($mysqli);
return $fetch;
}
}
This array (which i tried to print) is perfectly ready to do what i'd like.
My pain starts when i need to pass it to the following function in the same class, which perhaps calls a parent method to print the form:
public function Associa() {
$a = $this->EditDb();
$this->old_id = $a['old_id'];
$this->cognome = $a['cognome'];
$this->nome = $a['nome'];
$this->sesso = $a['sesso'];
$this->tipo_socio_id = $a['tipo_socio_id'];
$this->titolo = $a['titolo']; }
public function Body() {
parent::Body();
}
How do i have to pass this $fetch?
My implementation:
<?php
require_once '/classes/class.ConnessioneDb.php';
require_once '/classes/class.editForm';
$edit = new EditForm();
$edit->prel();
if ($edit->EditDb()) {
$edit->Associa();
$edit->Body();
if (if ($edit->EditDb()) {
$edit->Associa();
$edit->Body();) {
$edit->Associa();
$edit->Body();
your Editdb method is returning a string and you are checking for a boolean condition in if statement. this is one problem.
using fetch-
$fetch=$edit->EditDb();
$edit->Associa();
$edit->Body($fetch);
Posting the full code of it:
public function prel() {
$this->id= $_GET['id'];
}
public function EditDb () {
$connetti = new connessionedb();
$dbc = $connetti->Connessione();
$query = "SELECT * from table WHERE id = '$this->id'";
$mysqli = mysqli_query($dbc, $query);
if ($mysqli) {
$fetch = mysqli_fetch_assoc($mysqli);
return $fetch;
}
}
public function Associa($fetch) {
$this->old_id = $fetch['old_id'];
$this->cognome = $fetch['cognome'];
$this->nome = $fetch['nome'];
$this->sesso = $fetch['sesso']; //it goes on from there with many similar lines
}
public function Body() {
$body = form::Body();
return $body;
}
Implementation
$edit = new EditForm();
$edit->prel();
$fetch=$edit->EditDb();
$edit->Associa($fetch);
$print = $edit->Body();
echo $print;
Being an edit form base on a parent insert form, i added an if in the parent form that sees if is set an $_GET['id] and prints the right form header with the right form action. This was tricky but really satisfying.

Query result data is displaying after page reload

This is my code.
index.php file:
$viewer_id = $_SESSION['viewer_id'];
$db = new Database('144.76.6.45','5432','3331','asd','31sd23');
$db->querySelect("SELECT * FROM users WHERE vk_id = $viewer_id");
$row = $db->STH->fetch();
if(empty($row)){
require 'template/default/not_logged.php';
}
else {
require 'template/default/logged.php';
}
This part is understandable. Connecting to database, doing query. If viewer's id is in db - logged.php if not - not_logged.php
Lets say viewers id is already in db.
logged.php file:
<div id="text-right">
<p>Игровой ник: <?php $user->getEuName(); ?></p>
<p>Cоциум: <?php $user->getSociety(); ?></p>
<p>Основная профессия: <?php $user->getMainProfession(); ?></p>
<p>Дополнительная информация: <?php $user->getNotes(); ?></p>
<p>Ищу команду для совместной охоты: <?php $user->getWantTeam(); ?></p>
<div class="edit-info">Редактировать</div>
</div>
This methods are getting info from db.
class User extends Database {
public $vk_id;
public $eu_name;
public $eu_society;
public $eu_notes;
public $eu_want_team;
public $eu_data;
function __construct() {
parent::__construct('144.76.6.45','5432','eu','eu','eu123');
}
function getEuName() {
$this->querySelect("SELECT eu_name FROM users WHERE vk_id = $this->viewer_id");
$row = $this->STH->fetch();
print '<b>'.$row['eu_name'].'</b>';
}
function getSociety() {
$this->querySelect("SELECT eu_society FROM users WHERE vk_id = $this->viewer_id");
$row = $this->STH->fetch();
print '<b>'.$row['eu_society'].'</b>';
}
function getNotes() {
$this->querySelect("SELECT eu_notes FROM users WHERE vk_id = $this->viewer_id");
$row = $this->STH->fetch();
print '<b>'.$row['eu_notes'].'</b>';
}
function getWantTeam() {
$this->querySelect("SELECT eu_want_team FROM users WHERE vk_id = $this->viewer_id");
$row = $this->STH->fetch();
if($row['eu_want_team'] == 'TRUE') {
print '<b>Да</b>';
}
else {
print '<b>Нет</b>';
}
}
function getMainProfession() {
$this->querySelect("SELECT eu_main_profession FROM users WHERE vk_id = $this->viewer_id");
$row = $this->STH->fetch();
print '<b>'.$row['eu_main_profession'].'</b>';
}
}
$user = new User();
And this is user class with get methods.(he is included in index.php like database.php(db connection class) is).
Everything is ok, but when viewer comes to page, the data of methods(query results) doesn't show, they show only AFTER RELOAD! I don't know whats the problem. Please solution.
Thanks!

Fatal error: Call to a member function num_rows() on a non-object [duplicate]

This question already has answers here:
Reference - What does this error mean in PHP?
(38 answers)
Closed 8 years ago.
Hihow r u all?
I m trying to calculate basic salary with Particular employee_id but when i m trying to .. give me fatal error..
Fatal error: Call to a member function num_rows() on a non-object in D:\wamp\www\template\application\models\salary.php on line 112
my code is: model
<?php
class Salary extends Model
{
/*
Determines if a given person_id is a profile
*/
function exists($salary_id)
{
$this->db->from('salary_scale');
$this->db->where('id',$salary_id);
$this->db->where('deleted',0);
$query = $this->db->get();
return ($query->num_rows()==1);
}
/*
Determines if a given employee_id is a employee
*/
function exists_employee($employee_id)
{
$this->db->from('grade_history');
$this->db->where('employee_id',$employee_id);
$query = $this->db->get();
return ($query->num_rows()==1);
}
/*
Returns all the suppliers
*/
function get_all()
{
$this->db->from('salary_scale');
$this->db->where('deleted', 0);
$this->db->order_by("name", "asc");
return $this->db->get();
}
/*
*
* Gets information about a particular employees salary
*/
function grade_rules_info($salary_grade)
{
$this->db->from('salary_scale_rules');
$this->db->where('salary_grade',$salary_grade);
$query = $this->db->get();
if($query->num_rows()==1)
{
return $query->row();
}
else
{
//Get empty base parent object, as $item_id is NOT an item
$salary_obj=new stdClass();
//Get all the fields from items table
$fields = $this->db->list_fields('salary_scale_rules');
foreach ($fields as $field)
{
$salary_obj->$field='';
}
return $salary_obj;
}
}
/*
*
* Gets information about a particular employees salary
*/
function get_info($employee_id)
{
$this->db->from('allowance');
//$this->db->join('deductions', 'deductions.eid = allowance.eid');
$this->db->where('employee_id',$employee_id);
$query = $this->db->get();
if($query->num_rows()==1)
{
return $query->row();
}
else
{
//Get empty base parent object, as $item_id is NOT an item
$salary_obj=new stdClass();
//Get all the fields from items table
$fields = $this->db->list_fields('items');
foreach ($fields as $field)
{
$salary_obj->$field='';
}
return $salary_obj;
}
}
/**
* Gets information about a particular employees salary
*
**/
function get_grade_info($employee_id)
{
$this->db->from('grade_history');
$this->db->where('employee_id',$employee_id);
$query = $this->db->get();
if($query->num_rows()==1)
{
return $query->row();
}
else
{
//Get empty base parent object, as $employee_id is NOT an employee
$grade_obj=new stdClass();
//Get all the fields from items table
$fields = $this->db->list_fields('grade_history');
foreach ($fields as $field)
{
$grade_obj->$field='';
}
return $grade_obj;
}
}
/**
* Inserts or updates configuration data
*
*/
function save_grade(&$data, $employee_id=false)
{
if (!$employee_id)
{
if($this->db->insert('grade_history', $data))
{
$data['id']=$this->db->insert_id();
return true;
}
return false;
}
$this->db->where('id', $employee_id);
return $this->db->update('grade_history', $data);
}
// ------------------------ End of save_salary_cinfig function -----------------------------
/*
* Basic pay salary calculation
*/
function basic_pay($employee_id)
{
// Get grade information from grade_history table
// Get Particular person grade ifnormation by employ_id
$grade_info = $this->get_grade_info($employee_id);
$salary_grade = $grade_info->salary_grade;
$no_of_increment = $grade_info->number_of_increment;
// Get Grade rules information about particular grade by passing $salary_grade number
$grade_rules = $this->grade_rules_info($salary_grade);
$basic_amount = $grade_rules->basic_amount;
$increment = $grade_rules->increment;
$max_no_of_increment = $grade_rules->number_of_increment;
$max_amount = $grade_rules->max_amount;
return $basic_pay = $basic_amount + $increment*$no_of_increment;
}
}
?>
controller
<?php
require_once ("secure_area.php");
class Salaries extends Secure_area
{
function __construct()
{
parent::__construct('salaries');
}
function index()
{
$data['controller_name']=strtolower($this->uri->segment(1));
$data['form_width']=$this->get_form_width();
$data['manage_table']=get_profile_manage_table($this->Profile->get_all(),$this);
$this->load->view('salaries/manage',$data);
}
/*
Returns profile table data rows. This will be called with AJAX.
*/
function search()
{
$search=$this->input->post('search');
$data_rows=get_profile_manage_table_data_rows($this->Profile->search($search),$this);
echo $data_rows;
}
/*
Gives search suggestions based on what is being searched for
*/
function suggest()
{
$suggestions = $this->Profile->get_search_suggestions($this->input->post('q'),$this->input->post('limit'));
echo implode("\n",$suggestions);
}
/*
Loads the profile form
*/
function view($employee_id=-1)
{
//$data['salary_summary_info'] =$this->Salary->get_info($salary_id);
//$data['salary_deductions_summary_info'] =$this->Salary->get_deductions_info($salary_id);
$employee_id = array('' => '-- Select Employee ID --');
foreach($this->Profile->get_employee_id()->result_array() as $row)
{
$employee_id[$row['employee_id']]= $row['employee_id'];
}
$data['employee_id'] = $employee_id;
// $data['selected_employee_id'] = $this->Profile->get_info($employee_id)->employee_id;
$data['basic_pay'] = $this->Salary->basic_pay($employee_id);
$this->load->view("salaries/salary_summary_form", $data);
}
//--------------------------------------End view function-----------------------------------
/*
Loads the profile form
*/
function grade_view($employee_id=-1)
{
$data['salary_grade_info'] = $this->Salary->get_grade_info($employee_id);
$data['basic_pay'] = $this->Salary->basic_pay($employee_id);
$this->load->view("salaries/grade_view", $data);
}
//--------------------------------------End view function-----------------------------------
/*
Inserts/updates a profile
*/
function save_salary_grade($id=-1)
{
$grade_data = array(
'eid' =>$this->input->post('employee_id'),
'salary_grade' =>$this->input->post('salary_grade'),
'number_of_increment' =>$this->input->post('number_of_increment'),
'comments' =>$this->input->post('comments'),
'date' =>date('Y-m-d H:i:s')
);
if($this->Salary->save_grade($grade_data, $id))
{ //New profile
if($id==-1)
{
echo json_encode(array('success'=>true,'message'=>$this->lang->line('profiles_successful_adding').' '.
$grade_data['salary_grade'].' '.$grade_data['number_of_increment'],'id'=>$grade_data['eid']));
}
else //previous profile
{
echo json_encode(array('success'=>true,'message'=>$this->lang->line('profiles_successful_updating').' '.
$grade_data['salary_grade'].' '.$grade_data['number_of_increment'],'id'=>$grade_data['eid']));
}
}
else//failure
{
echo json_encode(array('success'=>false,'message'=>$this->lang->line('profiles_error_adding_updating').' '.
$grade_data['salary_grade'].' '.$grade_data['number_of_increment'],'id'=>$grade_data['id']));
}
}
/*
This deletes profiles from the profiles table
*/
function delete()
{
$profiles_to_delete=$this->input->post('ids');
if($this->Profile->delete_list($profiles_to_delete))
{
echo json_encode(array('success'=>true,'message'=>$this->lang->line('profiles_successful_deleted').' '.
count($profiles_to_delete).' '.$this->lang->line('profiles_one_or_multiple')));
}
else
{
echo json_encode(array('success'=>false,'message'=>$this->lang->line('profiles_cannot_be_deleted')));
}
}
/*
get the width for the add/edit form
*/
function get_form_width()
{
return 900;
}
}
?>
and view
<?php
echo form_open('salaries/save/'.$employee_id, array('id'=>'salary_summary_form'));
//echo form_open('salaries/save/', array('id'=>'salary_summary_form'));
?>
<div id="required_fields_message"><?php echo $this->lang->line('common_fields_required_message'); ?></div>
<ul id="error_message_box"></ul>
<fieldset id="salary_allowance_info">
<legend><?php echo $this->lang->line("salaries_allowance_info"); ?></legend>
<div class="field_row clearfix">
<?php echo form_label($this->lang->line('salaries_employee_id').':', 'employee_id', array('class'=>'required')); ?>
<div class='form_field'>
<?php echo form_dropdown('employee_id', $employee_id);?>
</div>
</div>
<div class="field_row clearfix">
<?php echo form_label($this->lang->line('salaries_allowance_basic_salary').':', 'basic_salary', array('class'=>'required')); ?>
<div class='form_field'>
<?php echo form_input(array(
'name'=>'basic_salary',
'id'=>'basic_salary',
'value'=>$basic_pay
));
?>
</div>
</div>
<div class="field_row clearfix">
<?php echo form_label($this->lang->line('salaries_allowance_house_rent').':', 'house_rent',array('class'=>'required')); ?>
<div class='form_field'>
<?php echo form_input(array(
'name'=>'house_rent',
'id'=>'house_rent',
// 'value'=>$salary_summary_info->house_rent
));
?>
</div>
</div>
<?php
echo form_submit(array(
'name'=>'submit',
'id'=>'submit',
'value'=>$this->lang->line('common_submit'),
'class'=>'submit_button float_right')
);
?>
</fieldset>
<?php
echo form_close();
?>
pls help me if any one
You don't test if your call to $db -> get() succeeded. I don't know the details of your $db class, but I suspect it only returns something if the call to it was successful. If the query fails does $db -> get() still return something?
Try doing a var_dump on what you get out of $db -> get() so you can see if it's returning what you think it's returning.
Fatal error: Call to a member function num_rows() on a non-object... is usually because there were no results return from a given query or possibly from a bad query.

Categories