I'm still trying to get my head around MVC I have a straight php/mysql page that basically works by getting select * FROM table1 then looping through the result set and on each loop running a Join to find sub project information..
but I can't figure out how to split this up and do it in MVC..
code is as below any help or pointers in the right direction would be appreaciated!
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM building";
$result=mysql_query($query);
$num=mysql_numrows($result);
$i=0;
while ($i < $num) {
    //for loop make a table
    //this is the heading info
    $b_id=mysql_result($result,$i,"id");
    $address=mysql_result($result,$i,"address");
    $description=mysql_result($result,$i,"description");
?>
    <table width="772px" border="0" align="center" cellpadding="5" cellspacing="0">
     <tr bgcolor="#4682B4" height="50">
      <td width="5%"></td>
      <td><font size="4" face="tahoma" color="white"><strong><? echo $address; ?><a href="http://localhost:8888/project-add.php?b_id=<? echo $b_id; ?>">Add Project</a></strong></font></td>
      <td bgcolor="#4682B4" align="center" width="50%"><input id="lnk<? echo $i; ?>" type="button" value="[+] Expand" onclick="toggle_visibility('tbl<? echo $i; ?>','lnk<? echo $i; ?>');"></td>
     </tr>
     <tr>
      <td colspan="3">
       <table width="103%" border="1" cellpadding="5" cellspacing="0" id="tbl<? echo $i; ?>" class="tbl">
        <?
        $query="SELECT project.id AS p_id, project.name AS p_name, project.description AS p_des, project.building_id as p_b_id, building.id AS b_id, building.address AS b_name
            FROM project JOIN building
            ON project.building_id = building.id
            WHERE building_id='$b_id'";
        $proj_result=mysql_query($query);
        $proj_num=mysql_numrows($proj_result);
        $j=0;
        while ($j < $proj_num) { //while 1
            $p_id=mysql_result($proj_result,$j,"p_id");
            $p_name=mysql_result($proj_result,$j,"p_name");
            $p_des=mysql_result($proj_result,$j,"p_des");
            $b_name=mysql_result($proj_result,$j,"b_name");
        ?>
        <tr>
         <td width="5%"></td>
         <td width="45%"><? echo $p_name; ?></td>
         <td width="50%" align="center">XXXXXXX</td>
        </tr>
        <?
            $j++;
        } //end while 1
        ?>
      </table>
      </td>
     </tr>
    </table>
    <?
    $i++;
}
mysql_close();
?>
 
     
    