Blank row is being inserted instead of values from sql table. |
[eluser]reghan[/eluser]
Hello I am having problems and I am new to codeignitor. Here is the code from my controller: Code: <?php here is the code from my view: Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> The output prints three bullets for the unordered list but does not print the values. There are three rows of data in the table so it knows that there is the correct amount of rows its is just not giving me the values. The table name is department and the colums are departmentId, departmentName, departmentDescription. I just want to list all the Department Names in the table. Anyone know what I am doing wrong? Thanks in Advance.
[eluser]gRoberts[/eluser]
On first thoughts: a) You are loading a model but using the Database class directly in your controller... b) $depart_list->result() returns an object, not an array, so your code would be: Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> You should really generate an array of departments from your model and then pass this array to your view. Using the empty function (http://php.net/manual/en/function.empty.php) you can then test to see if any departments are in the array, or even use the count function (http://php.net/manual/en/function.count.php) to test how many departments are in the array before showing. HTH
[eluser]reghan[/eluser]
Thanks for your reply. I have coded the following: Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> The Business Impact Analysis (BIA) is a process to determine the mission critical business functions and associated critical resources. This will be accomplished for Manitoba Lotteries by completing the following six components: •DepartmentName; ?> •DepartmentName; ?> •DepartmentName; ?> num_rows(); ?> I am still stumped. Thanks Again!
[eluser]gRoberts[/eluser]
Change lines that start with Code: <?= to start with Code: <?php echo and see if that fixes it?
[eluser]reghan[/eluser]
Yes that fixes it! Thanks! Do you know why that was the problem? I thought I could use the alternative syntax? Unless I was doing it wrong I am new to php and codeignitor.
[eluser]gRoberts[/eluser]
Short tags are enabled within your PHP's INI file: http://www.php.net/manual/en/ini.core.ph...t-open-tag |
Welcome Guest, Not a member yet? Register Sign In |