How can i use mysql_fetch array or an alternative to display output in an MVC structure?
Model - Connects to the database and a function that queries the table for details and returns the result
Controller - receive result from function and passes it to view
View - displays the table values, item_id and item_name in a drop-down list using a loop
Without an MVC structure, the process would look like this
<?php
$con = mysql_connect("localhost", "peter", "abc123");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
$db_selected = mysql_select_db("test_db",$con);
$sql = "SELECT * from Person WHERE Lastname='Refsnes'";
$result = mysql_query($sql,$con);
print_r(mysql_fetch_array($result));
mysql_close($con);
?>
How can the same be achieved in an MVC. The challenge is how to get the entire array stored in result, to be displayed correctly in view.