How to select all or get all the data in a table? |
[eluser]towki[/eluser]
I couldnt figure out waht wrong with my code, what i wanted is to display all the rows in a table but instead it displays only one row, only the latest data added to the database was being displayed. This if my function in my controller(criminal.php) Code: public function viewRecords(){ Code: public function view_records() And for my view(view_data.php): Code: <h2>Criminal Records System</h2> Pls anyone help me to clear this out. Im basically new to php and codeIgniter :-)
[eluser]mr_prasanna[/eluser]
Replace Code: <?php foreach ($results as $row) ?> with this Code: <?php foreach ($results as $row) ?> Basically, endforeach is missing.
[eluser]skunkbad[/eluser]
In the view, the way you wrote the foreach is probably wrong. mr_prasanna was right. I was going to suggest you try: Code: <?php Even though you are using alternative syntax for your foreach, you have left out the colon(, so I'm not sure it's going to work. Personally, I don't like the alternative syntax, and think you should use standard syntax because alternative syntax is cluttered.
[eluser]towki[/eluser]
[quote author="mr_prasanna" date="1342365113"]Replace Code: <?php foreach ($results as $row) ?> with this Code: <?php foreach ($results as $row) ?> Basically, endforeach is missing.[/quote] Thanks mr_passana for your reply. But I didnt get it to work when i tried your code. It show me this error Quote:Parse error: syntax error, unexpected T_ENDFOREACH in C:\xampp\htdocs\basicwebsite\application\views\view_data.php on line 6
[eluser]towki[/eluser]
[quote author="skunkbad" date="1342365392"]In the view, the way you wrote the foreach is probably wrong. mr_prasanna was right. I was going to suggest you try: Code: <?php Even though you are using alternative syntax for your foreach, you have left out the colon(, so I'm not sure it's going to work. Personally, I don't like the alternative syntax, and think you should use standard syntax because alternative syntax is cluttered.[/quote] I have tried your code skunkbad, and my problem was solved! But I dont understand why mr_passana was suggesting a endforeach while your code had no endforeach at all. Was my problem was caused by using alternative syntax?? Thanks to all of you for fast reply!
[eluser]towki[/eluser]
Never mind. I knew it now. It was just the colon im missing and a endforeach in my syntax |
Welcome Guest, Not a member yet? Register Sign In |