I am developing a forum in php & MySQL for intranet.I started my development by creating a DAO from my database operation then In my all php pages i use scriplets with in the html code to fetch data i require from my DAO.
<htlm>
<body>
<table>
<tr><th>Subject</th><th>By</th><th>Date</th></tr>
<?php
$posts=DAO.getPostDAO().getPostByUserId(userId);
for($i=0;$i<count($posts);$i++)
{
$post=$posts[$i];
?>
<tr>
<td><?php echo $post->subject; ?></td>
<td><?php echo $post->userId; ?></td>
<td><?php echo $post->createdAt; ?></td>
</tr>
<?php } ?>
</table>
I have red about MVC pattern ,I understand the concept but I dont know how to implement it while writing code so can you help me to convert this to MVC pattern.
Can you tell me how should i divide this in to module,view and controller and where does the DAO fit in all this? Is is a part of controller?
I would suggsest you use an existing PHP MVC framework (Symfony, CakePHP, Zend Framework, …) and learn from that.
Your question is just to big to answer here, whole books are written on the subject. By using and studying an existing solution you’ll learn everything you need, and will (probably) be able to roll your own framework once you’re done.