//==========================================
 //		EXERCISE CODE
 //==========================================
 //print $postData[0]['threadTopic'] . "<BR>";
 //for ($i = 0; $i < $totalRows; ++$i) {
 //$postData[$i]['newPosition'] = $i;
 //}
 //print $postData[1]['newPosition'] . "<BR>";
 //================================================================
 //	FIND OUT HOW MANY REPLIES THERE ARE FOR EACH POST
 //	ADD A NEW VALUE TO THE 2D ARRAY
 //===============================================================
 $cnt = count($postData);
 for ($i = 0; $i < $cnt; ++$i) {
     $rep = $postData[$i]['threadID'];
     $repSQL = getReplySQL($forum, $rep);
     $result = mysql_query($repSQL);
     $numRows = mysql_num_rows($result);
     $postData[$i]['numRows'] = $numRows;
 }
 //================================================================
 //	FIND OUT WHICH MEMBER POSTED, AND ADD IT THE 2D ARRAY
 //===============================================================
 for ($i = 0; $i < $cnt; ++$i) {
     $memb = $postData[$i]['memberID'];
     $memSQL = "SELECT * from members WHERE memberID = '{$memb}'";
     $result2 = mysql_query($memSQL);
     if ($result2) {
         $db_field = mysql_fetch_assoc($result2);
         $memName = $db_field['username'];
         $postData[$i]['member'] = $memName;
 $server = "127.0.0.1";
 $db_handle = mysql_connect($server, $user_name, $password);
 $db_found = mysql_select_db($database, $db_handle);
 if ($db_found) {
     //================================================================
     //	GET THE SQL FOR ALL THE REPLIES
     //================================================================
     $repCode = getReplySQL($secCode);
     $repCode = $repCode . "'" . $postID . "'";
     $result = mysql_query($repCode);
     $totalRows = mysql_num_rows($result);
     if ($totalRows != 0) {
         //================================================================
         //	GET SOME SQL TO LIMIT THE NUMBER OF ROWS FROM DATABASE
         //================================================================
         $repCode = getReplySQL($secCode);
         $repCode = $repCode . "'" . $postID . "'" . " LIMIT " . $pageID . ", 10";
         //================================================================
         //	RETURN THE LIMITED ROWS AND PUT THEM INTO AN ARRAY
         //================================================================
         $result = mysql_query($repCode);
         $numRows = mysql_num_rows($result);
         if ($result) {
             for ($i = 0; $i < $numRows; ++$i) {
                 $replyData[$i] = mysql_fetch_array($result);
             }
             //================================================================
             //	FIND OUT HOW MANY LINKS ARE NEEDED
             //===============================================================
             $cnt = count($replyData);
             //$endNum = $totalRows;
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $secID = $_POST['h1'];
    $posID = $_POST['h2'];
    $memID = $_POST['h3'];
    $repText = $_POST['post'];
    $strCount = strlen($repText);
    if ($strCount > 255) {
        print "too many characters in your reply";
    } else {
        $repText = "'" . $repText . "'";
        $posID = "'" . $posID . "'";
        $memID = "'" . $memID . "'";
        $date_today = date("Y-m-d H:i:s");
        $date_today = "'" . $date_today . "'";
        $tableSQL = getReplySQL($secID);
        $tableSQL = $tableSQL . "(" . $posID . "," . $memID . "," . $repText . "," . $date_today . ")";
        $user_name = "root";
        $password = "";
        $database = "dbforum";
        $server = "127.0.0.1";
        $db_handle = mysql_connect($server, $user_name, $password);
        $db_found = mysql_select_db($database, $db_handle);
        if ($db_found) {
            $result = mysql_query($tableSQL);
            mysql_close($db_handle);
            if ($result) {
                print "Your Reply has been added to the Forum." . "<BR>";
                print "<A HREF = forumTest.php>Back to the forum</A>" . "<BR>";
            } else {
                print "no results" . "<BR>";