I am writing a program that extracts data from a mysql database and displays it on a table but i get the labels displaying more than once. How do i get it to display a "normal" table with labels appearing only once at the top.
the code is as follows:
include('connection.php');
for ($x = 2; $x <= 4; $x++) {
$crop_farmer = mysql_fetch_array(mysql_query("SELECT crop FROM farmer where mem_id = '$x'"));
$crop_farmer = $crop_farmer[0];
$et0 = mysql_fetch_array(mysql_query("SELECT et0 FROM weather where timedate = 0"));
$et0 = $et0[0];
$texture = mysql_fetch_array(mysql_query("SELECT texture FROM farmer where mem_id = '$x'"));
$texture = $texture[0];
$contact = mysql_fetch_array(mysql_query("SELECT phone FROM farmer where mem_id = '$x'"));
$contact = $contact[0];
$farmerID = mysql_fetch_array(mysql_query("SELECT mem_id FROM farmer where mem_id = '$x'"));
$farmerID = $farmerID[0];
$area_farmer = mysql_fetch_array(mysql_query ("SELECT area FROM farmer WHERE mem_id = '$x'"));
$area_farmer = $area_farmer[0];
$depth = mysql_fetch_array(mysql_query("SELECT rootdepth FROM mad_depth where crop = '$crop_farmer'"));
$depth = $depth[0];
$mad = mysql_fetch_array(mysql_query("SELECT mad FROM mad_depth where crop = '$crop_farmer'"));
$mad = $mad[0];
$kc = mysql_fetch_array(mysql_query("SELECT kcd FROM crop where crop = '$crop_farmer'"));
$kc = $kc[0];
$am = mysql_fetch_array(mysql_query("SELECT am FROM soil where texture = '$texture'"));
$am = $am[0];
$IC = ($am * $depth * $mad)/($kc * $et0);
$IC = number_format($IC, 0);
$DRT = $et0 * $kc * 1.125*60;
$DRT = number_format($DRT, 0);
$RN = mysql_fetch_array(mysql_query("SELECT nd FROM crop WHERE crop = '$crop_farmer'"));
$RN = $RN[0];
$RP = mysql_fetch_array(mysql_query("SELECT pd FROM crop WHERE crop = '$crop_farmer'"));
$RP = $RP[0];
$RK = mysql_fetch_array(mysql_query("SELECT kd FROM crop WHERE crop = '$crop_farmer'"));
$RK = $RK[0];
$N = $RN * $area_farmer/23;
$N = number_format($N, 2);
$P = $RP * $area_farmer/23;
$P = number_format($P, 2);
$K = $RK * $area_farmer/30;
$K = number_format($K, 2);
echo "<table border='1'>";
echo "<tr> <th>Contact</th> <th>Farmer ID</th> <th>Crop</th> <th>DRT (Minutes)</th> <th>IC (Days)</th> <th>Urea(50 Kg Bag(s))</th> <th>TSP(50 Kg Bag(s))</th> <th>MOP(50 Kg Bag(s))</th>";
echo '<tr><td>'.$contact, "</td><td>".$farmerID."</td><td>" .$crop_farmer."</td><td>" .$DRT."</td><td>".$IC ."</td><td>" . $N."</td><td>". $P."</td><td>". $K;
echo "</td></tr>";
echo "</table";
}
Any help will be appreciated.