Welcome Guest, Not a member yet? Register   Sign In
Querying result in view

Hello, I have a problem.
I have php code

function display() {
global $database;
$q = "SELECT value1, value2, value3 FROM " . TBL_1 . " LIMIT 0,10";
$result = $database->query($q);
$num_rows = mysql_numrows($result);
if (!$result || ($num_rows < 0)) {
echo "error";
if ($num_rows == 0) {
for ($i = 0; $i < $num_rows; $i++) {
$val1 = mysql_result($result, $i, "value1");
$val2 = mysql_result($result, $i, "value2");
$val3 = mysql_result($result, $i, "value3");
echo "<div id=\"content_main_entry\"><a >
<span class=\"content_main_entry_value\">" . $val2 . "</span>
<span class=\"content_main_entry_value\">" . $val3 . "</span>
<div id=\"content_main_entry_enroll\"></div>";

And I want to create the same using the codeigniter code. I've tried but I dunno how to send all the data into the view. I tries in controller setting variable
$data['records'] = $this->db->get(TBL_1);
And now I send this variable to my view

And I'm stuck... Have no idea how to access all the data (in the way I showed in my php code)

I would be thankful for help

[eluser]Alias M2K[/eluser]
Man, you have to get the data in the controller. Then load them into the view. In the view, use foreach to sort out and manipulate the data. Ok?

Theme © iAndrew 2016 - Forum software by © MyBB