chu-boi Posted October 27, 2009 Share Posted October 27, 2009 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! Quote Link to comment https://forums.phpfreaks.com/topic/179132-quick-question-on-pulling-out-and-displaying-data/ Share on other sites More sharing options...
fenway Posted October 31, 2009 Share Posted October 31, 2009 I don't see a single mysql query anywhere in there. Quote Link to comment https://forums.phpfreaks.com/topic/179132-quick-question-on-pulling-out-and-displaying-data/#findComment-948394 Share on other sites More sharing options...
chu-boi Posted November 2, 2009 Author Share Posted November 2, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/179132-quick-question-on-pulling-out-and-displaying-data/#findComment-949386 Share on other sites More sharing options...
fenway Posted November 14, 2009 Share Posted November 14, 2009 Since I have no idea what codeigniter is, I can't really help you. Sorry. Without mysql statements, there's not much i can do. Quote Link to comment https://forums.phpfreaks.com/topic/179132-quick-question-on-pulling-out-and-displaying-data/#findComment-957443 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.