Problem in display (view) |
[eluser]johnmiller[/eluser]
Hey… I have a table called ‘users’ with fields ‘name, address’. There are 100 records in this table. I need to display all the 100 records in the ‘view’. But I am getting only one record(first record). How to write the view which displays all the 100 records? Can you please help me? The below given are the model and controller Model (blogmodel.php) Code: <?php Controller (blog.php) Code: <?php
[eluser]beemr[/eluser]
Code: $query->result_array(); Code: $query->row_array(); Row_array() returns a single row
[eluser]johnmiller[/eluser]
Thanks beemr, but if i use Code: result_array(); The below is the view (blogview.php) Code: <html> Code: </td>
[eluser]beemr[/eluser]
So then, your results are an array. In the red text above, you would remove the surrounding <td> and insert Code: <td><?=$value['name']?></td> see the docs
[eluser]elvix[/eluser]
just do a print_r($value) in there and it should print out all the values contained in the $value array. then just place the appropriate value ($value['something']) where you want it. when it comes to arrays, print_r is your best friend.
[eluser]johnmiller[/eluser]
Thanks a lot everybody... I tried the below code and it is working now... Code: <?php $counter = count($query);?> Thanks a lot to everybody who helped me... Someone can use this code in the future...
[eluser]Randy Casburn[/eluser]
You can try this too... Code: <table border="1"> Randy
|
Welcome Guest, Not a member yet? Register Sign In |