Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8371563
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T14:11:36+00:00 2026-06-09T14:11:36+00:00

I am fairly new to codeigniter. I have the following code in my views/check_availability/index.php

  • 0

I am fairly new to codeigniter.

I have the following code in my views/check_availability/index.php file:

<?php $type = $_POST['type']; ?>

<a href="/reservation/check_availability/create">Create Reservation</a>

<?php foreach ($check_availability as $check_availability_item): ?>

    <h2><?php echo $check_availability_item['room_type'] ?></h2>
    <div id="main">
        <?php echo $check_availability_item['room_description'] ?>
    </div>
    <p><a href="check_availability/<?php echo $check_availability_item['id'] ?>">View article</a></p>

<?php endforeach ?>

This is my code under models/check_availabiliy_model.php file

public function check_availability($type = FALSE)
{
    if ($type === FALSE)
    {
        $query = $this->db->get('lf_rooms');
        return $query->result_array();
    }

    $query = $this->db->get_where('lf_rooms', array('type' => $type));
    return $query->row_array();
}

This is the code in my controllers/check_availability.php file

public function index()
{
    $data['check_availability'] = $this->check_availability_model->check_availability();
    $data['title'] = 'Available Roooms';

    $this->load->view('templates/header', $data);
    $this->load->view('check_availability/index', $data);
    $this->load->view('templates/footer');
}

Under views/check_availability/index.php file I want to filter the room_type field when I call the check_availability function based on the value from POST method like $type = $_POST[‘type’].

Currently this is the code that I used to query all the record from lf_rooms table:

<?php foreach ($check_availability as $check_availability_item): ?>

but how can I pass the value of $type variable to check_availability function?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T14:11:37+00:00Added an answer on June 9, 2026 at 2:11 pm

    You should get the POST parameter in the controller, query the database accordingly and only display the results in the view. The view should not hold any logic.

    public function index()
    {
        $type = $this->input->post('type', TRUE);
    
        $data['check_availability'] = $this->check_availability_model->
                                      check_availability($type);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Fairly new to asp.net Mvc and jquery. Have the following code working fine, but
I am fairly new to PHP and Codeigniter so im sure this will be
I am fairly new to php and mysql but I have created a small
I am fairly new and just started to use Codeigniter, and have come across
I’m fairly new to Codeigniter. I have been reading the user guide extensively but
fairly new to Objective-C and iOS development (coming from PHP) and I have a
I am new to CodeIgniter and Xmlrpc in general, so i have a fairly
I am new to fairly new to AS3 and I have found myself needing
Fairly new to CodeIgniter, still grasping the MVC approach. I'm just wondering what's the
Being fairly new to C++ I have a question bascially concerning the g++ compiler

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.