Jump to content

Quick question on pulling out and displaying data


chu-boi

Recommended Posts

Hi all,

    I'm currently developing a webpage that displays user results derived for picks they make.

these results are graphed using the jquery visualize plugin. this plugin allows you to display data stored in an HTML table as a graph.

for the graph to be properly displayed the data in the table has to be in the following order:

<caption> your graph title </caption>

<table>

    <th>

      <tr>

        <td> your x_axis values </td>

      </tr>

      </th>

      <tbody>

        <tr>

          <th> your series title </th>

          <td> your y_axis values </td>

          </tr>

      </tbody>

    </table>

    what i've done so far:

  So far i've put the above values into seperate columns in a database table

  the table has the following columns:

  graphTitle, x_axisVal, seriesTitle, y_axisVal

My problem is pulling out the values and using it to build an HTML table that will then be graphed

I'm working with codeigniter that uses a controller to display basically everything. the code i've is something like this:

The Model:

  class Wk_pick_res_model extends Model{

  function Wk_pick_res_model(){

      parent::Model();

                        }

  function get_val(){

  $this->load->database();

  $this->db->select('x_axisVal');

              $query_x = $this->db->get('weekly_pick_res','11');

  foreach ($query_x->result() as $row_x){

      $x_val = $row_x->x_axisVal;

                                    }

  $res_array['results'] = array('x_val'=>$x_val

);

         

  return $res_array;

                                                            }

                                                  }

          The Controller:

      <?php

    class User_res extends Controller{

    function User_res(){

parent::Controller();

                    }

function index(){

$this->load->view('disp_test');

                }

    function output_res(){

    $this->load->model('Wk_pick_res_model');

$res_disp = $this->Wk_pick_res_model->get_val();

$this->load->view('testing_SQL', $res_disp); //this sends the values retrieved from the model to a view file as an array

                    }

          }

?>

  The view file:

      <html>

<body>

<table>

  <tr>

    <td>

<?php foreach($results as $x_res): ?>

  <?=$x_res?>

<?php endforeach ?>

<?php echo "<br/>" ?>

</td>

</tr>

</table>

  </body>

</html>

  ... the x_axisVal column contains values from 0% to 100%, when I load the view file, all I get is '100%'. I think the server must have looped through the array returned by the model and ended at the last array element which it then displays. Is there any I can make it display every element(x_axisVal records) as it loop through the array?

Any and all help will be greatly appreciated

Thanks a bunch!

 

Link to comment
Share on other sites

Hi thanx for replying,

                            The mySQL query is in the MODEL SECTION, i used codeigniter shorthand to connect to the database, select the table and the column that data should be pulled from. Right now it only displays a single row from the column, but I need it to display all rows. I need to set up a loop to do this but I'm not sure whether to do so in the model file or the controller file.

Any suggestions would be greatly appreciated, again thanx for the reply.

 

Chuboi

Link to comment
Share on other sites

  • 2 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.