sql
html
php
css
c
ajax
python
linux
xcode
regex
multithreading
eclipse
silverlight
facebook
tsql
delphi
apache
mvc
jsp
dom
This is just a suggestion to your question since I don't know which field you want to stop duplicating. Here I am proposing you a way to stop printing the first_name if it is duplicating again and again. Here you have to make sure your query is ordered by that value set as well.
Please tr this code.
EDITED.
<?php session_start(); ?> <?php require('includes/dbconnect.php'); ?> <?php require 'includes/header.inc.php'; ?> <?php $matric_no = mysql_real_escape_string($_POST['matric_no']) ; if ( $_POST['matric_no'] == "") { echo"<div id=\"contentRight\">"; echo"<div id=\"msg\">" ; echo "You didn't enter a <span style=\"color:red\"> Matric Number</span>"; echo"</div>" ; echo"</div>" ; exit(); } $query = "SELECT matric_no FROM main_table WHERE main_table.matric_no = '$_POST[matric_no]'"; $result = mysql_query($query) ; $duplicates = mysql_num_rows($result); if ($duplicates < 1) { echo"<div id=\"contentRight\">"; echo"<idv id=\"msg\">" ; echo "You dont have a record for <span style=\"color:red\"> $matric_no</span>" ; echo"</div>" ; echo"</div>" ; exit(); } { $query = mysql_query("SELECT main_table.matric_no , main_table.session, main_table.semester , main_table.course_name , (test+exam+practical) AS Total, students.first_name, students.last_name, students.other_name, students.level FROM main_table INNER JOIN students ON main_table.matric_no = students.matric_no WHERE main_table.matric_no = '$_POST[matric_no]' ORDER BY students.first_name") or die (mysql_error()); $matchingString = ""; while ($row = mysql_fetch_assoc($query)) { echo $row["matric_no"] ; echo "<br />"; echo $row["session"]; echo "<br />"; echo $row["semester"]; echo "<br />"; echo $row["course_name"]; echo "<br />"; $checkingString = $row["first_name"] . $row["last_name"] . $row["other_name"] . $row["level"]; if($matchingString != $checkingString) { echo $row["first_name"]; echo "<br />"; echo $row["last_name"]; echo "<br />"; echo $row["other_name"]; echo "<br />"; echo $row["level"]; echo "<br />"; $matchingString = $checkingString; } } } ?>
ANSWER AFTER THE QUESTION MODIFICATION
Just change your two loops as bellow and see.
for ($i = 0; $i < ($number_cols - 4); $i++)