tags:

views:

115

answers:

3

Dear all,

In codeigantor framework How i execute a select query with where clause and put the value into a table and return the table??

example: function abc($input) { $query=........where name='.$input.'; ........ .......

return table; }

...........how i do it ? pls help..

thanks riad

A: 

the userguide is very helpful for these types of basic questions

http://codeigniter.com/user_guide

Tom Schlick
+2  A: 

Tom has a very good point. All of this is in the User Guide, but just to direct you to which bits, try this super-fun three step challenge:

  1. Creating queries with ActiveRecord
  2. Generating Query Results
  3. HTML Table Class

Tadaaaaa! Magic. In the future, have a shufty around the CodeIgniter User Guide: Table of Contents.

Phil Sturgeon
+1  A: 

i already prepare this things pls see the code below:

function getSearchResults ($function_name, $description = TRUE)
{
     $this->db->like('songName', $function_name);
    $this->db->orderby('songName');
    $query = $this->db->get('tbl_rbt');
    if ($query->num_rows() > 0) 
    {
        $output = '<table width="800" border="1" class="output_table">';
        foreach ($query->result() as $function_info) 
        {
            if ($description) 
            {               
                $output .= '<tr ><td>'.$function_info->songName.'</td>';
                $output .= '<td>'.$function_info->albumName.'</td>';                    
                $output .= '<td>'.$function_info->artistName.'</td></tr>';

            } 
            else 
            {
                $output .= '<tr>'.$function_info->songName.'</tr>';
            }
        }
        $output .= '</table>';
        return $output;
    } 
    else 
    {
        return '<p>Result not found.</p>';
    }
  }

thanks to all riad

riad