Welcome Guest, Not a member yet? Register   Sign In
how i can to show specific record from a table
#4

(10-31-2018, 06:31 PM)king_ahwaz Wrote: could you please show my an example, i'm not an expert.

thanks

What needs to be done depends completely on how the table(s) are structured. So it's really hard to provide a complete and accurate example.

That being the case, I'll make some stuff up. The table "projects" has the following fields

"projID"  an auto incrementing integer and primary key for the table
"catID"  an integer representing various categories
"image" the actual image data
"title" a string

A model function could look something like this

PHP Code:
public function get_last_five($category)
{
 
   $this->db
            
->select('image, title')
 
           ->order_by('projID''DESC');  //reverse the natural sort order

 
   // get five rows starting at the first row
 
   $query $this->db->get_where('projects', array('catID' => $category), 50);
 
    // make sure that get_where worked - it will be false if it failed
 
   if($query !== FALSE)
 
   {
 
      return $query->result();  //returns an array of "row" objects
 
   }


The Query Builder documentation is HERE
and everything you need to know about generating query results is HERE.
Reply


Messages In This Thread
RE: how i can to show specific record from a table - by dave friend - 11-01-2018, 10:06 AM



Theme © iAndrew 2016 - Forum software by © MyBB