Help needed: how to pass multiple queries with different table names to the view ? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: Help needed: how to pass multiple queries with different table names to the view ? (/showthread.php?tid=61084) |
Help needed: how to pass multiple queries with different table names to the view ? - El Forum - 09-14-2014 [eluser]adelregh[/eluser] Hi guys, I am very new to codeigniter. I am trying to send a query from the controller to the view. I have to different functions with two different queries. How can I style the two different results in the single view I have? Does that make sense? here is my code in the controller: Code: public function publications() here is my code in the view: Code: <div class="col-lg-12"> any help would greatly appreciated Help needed: how to pass multiple queries with different table names to the view ? - El Forum - 09-14-2014 [eluser]InsiteFX[/eluser] CodeIgniter Users Guide - HTML Table Class Help needed: how to pass multiple queries with different table names to the view ? - El Forum - 09-14-2014 [eluser]adelregh[/eluser] Thank you very much InsiteFX for your response. My question is not how to alter a table! My question is, when you pass different queries from different functions from the controller (like "publications" and "teaching" in my code stated above), how do I manage to display the related one on the page?? I am really sorry if this does not make sense because I am a beginner at this Help needed: how to pass multiple queries with different table names to the view ? - El Forum - 09-14-2014 [eluser]adelregh[/eluser] Never mind I solved it with "switch", though I am curious why "if" did not work?? If someone could tell me how to set a font-style for each echo without having to play with css I would be grateful . here is the code: Code: foreach ($query->result() as $row) Help needed: how to pass multiple queries with different table names to the view ? - El Forum - 09-14-2014 [eluser]Tim Brownlaw[/eluser] Your IF never worked as you were setting $name = 'publications' which just so happens to evaluate to TRUE Code: if ($name = 'publications') So you should of had... Code: if ($name == 'publications') Code: elseif ( $name == 'teaching') The switch way of doing things works well... And welcome to CI Land Help needed: how to pass multiple queries with different table names to the view ? - El Forum - 09-14-2014 [eluser]adelregh[/eluser] I knew these rules but I was soooo blind. That is why it worked with the switch statement in witch I could not miss type Anyway, thank you very much Help needed: how to pass multiple queries with different table names to the view ? - El Forum - 09-14-2014 [eluser]InsiteFX[/eluser] If you use the HTML Table Class you can create a Table template and set the styles in it see the Users Guide. In your Controllers __construct() add this: Code: // Needs to be updated to CI ver 2.2.0 Help needed: how to pass multiple queries with different table names to the view ? - El Forum - 09-14-2014 [eluser]adelregh[/eluser] Got it, thanks |