User Tools

Site Tools


codeigniter

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
codeigniter [2010/06/16 20:42] – javascript json array rfilecodeigniter [2011/03/07 21:09] (current) rfile
Line 142: Line 142:
  
 </code> </code>
 +</box>
 +<box|use of row_array()>
 +<code php>
 +  /**
 +     * Note the use of row_array to get
 +     * array of one row instead of object
 +     * this will matter later in the whole 
 +     * array that is passed to the view
 +     * @param string $wfield
 +     * the column we want to average
 +     * @param string $avgname
 +     * this is for the "as" clause
 +     * @param string $tablename
 +     * the name of the table the column is in
 +     * @return array
 +     *
 +     */
 +    function get_avg($wfield,$avgname,$tablename) {
 +        $this->db->select_avg($wfield,$avgname);
 +        $query = $this->db->get($tablename) ;
 +        $avgdata = $query->row_array() ;
 +        return $avgdata ;
 +    }
 +
 +    }
 +
 +
 +</code>
 +</box>
 +<box | second database>
 +<code php>
 +
 +<?php
 +class Model_old_info extends CI_Controller {
 +
 +       function __construct()
 +       {
 +            parent::__construct();
 +            // Your own constructor code
 +            $CI =& get_instance() ;
 +       $CI->oldbp = $this->load->database('oldbp', TRUE);
 +       $this->oldbp =& $CI->oldbp;
 +       }
 +       function get_old_records() {
 +
 +
 +       $table_name = 'old_blood_pressure' ;
 +       $oldbprec = $this->oldbp->get($table_name);
 +       foreach ($oldbprec->result()as $row) {
 +             $table_data[] = $row ;
 +          }
 +          return $table_data;
 +   }
 +       }
 +
 +</code>
 +
 +
 +
 +'oldbp' is in the codeigniter database config file
 +
 +
 </box> </box>
  
Line 148: Line 210:
 <box  green 70% |been working on this for a while> <box  green 70% |been working on this for a while>
 <code javascript> <code javascript>
-$(document).ready(function() {+$(function() {
 $('#submit_item').click(function(){ $('#submit_item').click(function(){
 var wpt = $('select#wpt_pick').val(); var wpt = $('select#wpt_pick').val();
codeigniter.1276738967.txt.gz · Last modified: 2010/06/16 20:42 by rfile