Welcome Guest, Not a member yet? Register   Sign In
Questions on working with db results
#1

[eluser]braca86[/eluser]
hello im new to the codeignite so i hope someone can help me...

i made a query that is pulling some informactions from database and everything is working fine but i cant see the records from database... how? well i make ordered list and i can se for instance 4record but they are not displaying... like this

1.
2.
3.
4.
instead of this

1. first record
2. second
3. third
4. fourth

code:
conroler:
Code:
function index()
{
$data['query'] = $this->db->get('tablefield');
    $this->load->view('blog_view', $data);
}
view:
Code:
<?php foreach($query->result() as $row): ?>
<ol>
<li> &lt;?php $row->record ?&gt; </li>
</ol>
<hr>
&lt;?php endforeach; ?&gt;
#2

[eluser]Pascal Kriete[/eluser]
In your controller:
Code:
$query = $this->db->get(‘tablefield’);
echo '<pre>';
print_r($query->result());
echo '</pre>';
exit;

What does that give you?
#3

[eluser]braca86[/eluser]
now its working i can see text.. but its pulling all informaction in array with too many info

Array
(
[0] => stdClass Object
(
[ID] => 10
[IDAnketaSpisak] => 1
[Odgovor] => onako
[RedniBroj] => 5
)

[1] => stdClass Object
(
[ID] => 11
[IDAnketaSpisak] => 1
[Odgovor] => da
[RedniBroj] => 4
)

[2] => stdClass Object
(
[ID] => 12
[IDAnketaSpisak] => 1
[Odgovor] => ne
[RedniBroj] => 2
)

[3] => stdClass Object
(
[ID] => 13
[IDAnketaSpisak] => 1
[Odgovor] => delimicno
[RedniBroj] => 1
)

[4] => stdClass Object
(
[ID] => 14
[IDAnketaSpisak] => 1
[Odgovor] => mozda
[RedniBroj] => 3
)
#4

[eluser]Mat-Moo[/eluser]
Code:
<ol>
&lt;?php
foreach($query->result() as $row)
{
  print "<li>".$row->fieldcolumn."</li>";
}
?&gt;
</ol>
$row will be an object of fields in your database, so if your database has "Id" and "Name" as two columns then use $row->Id and $row->Name.
#5

[eluser]braca86[/eluser]
yeah Thanks a lot.. that solve the problem thanks mate...
#6

[eluser]braca86[/eluser]
just one more thig... i neet to pass selected radio and info into 3rd table ... any hints???

Code:
&lt;FORM NAME ="form" METHOD ="GET" ACTION ="process.php"&gt;
&lt;?php

$query = $this->db->query('SELECT `anketaodgovori`.`Odgovor`, `anketaodgovori`.`RedniBroj`, `anketaodgovori`.`ID` FROM `anketaspisak` LEFT JOIN `bazaanketa`.`anketaodgovori` ON `anketaspisak`.`ID` = `anketaodgovori`.`IDAnketaSpisak` WHERE (`anketaspisak`.`Aktivna` =1)
ORDER BY `anketaodgovori`.`RedniBroj` ASC');

foreach ($query->result() as $row)
{    
    echo '&lt;input type="radio" name="odgovor" value='.$row-&gt;ID ;';/>' ;    
    echo $row->RedniBroj;    
    echo $row->Odgovor.'</li>';  
}
?&gt;
    
&lt;INPUT TYPE = "Submit" Name = "Submit"  VALUE = "Submit"&gt;
&lt;/FORM&gt;
#7

[eluser]braca86[/eluser]
i'm seaching for soluction but nothing any tutorial or somethig that can help me?
#8

[eluser]Mat-Moo[/eluser]
This really needs to be moved out of bug reports, as it has nothing to do with bugs in CI.

Why is your action set to another php file, it should be a CI controller/method? Also you have mixed in the model with the form which is out of context for CI (Or have you just put up spots of code). As for passing on info, what code have you got?
#9

[eluser]Pascal Kriete[/eluser]
Moved. Please start using [code ] [/code ] as well, makes it a lot easier to read.




Theme © iAndrew 2016 - Forum software by © MyBB