Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

while loop repeating same data

$
0
0

I have a MySQL query which gets the required data ok. But when I submit the results into the HTML table it displays the data ok but it repeats it over and over.

Here is my code:

 

$result=mysql_query($sql) or die(mysql_error());
if($result)
{
 ?>
<table name='details' border='2'>
<thead>
 <tr>
  <th>Customer ID</th>
  <th>Forename</th>
  <th>Surname</th>
  <th>Email</th>
  <th>Mobile Number</th>
  <th>Home Number</th>
  <th>Address Line 1</th>
  <th>Address Line 2</th>
  <th>Address Line 3</th>
  <th>Postcode</th>
  <th>Job Reference Number</th>
  <th>Manufacturer</th>
  <th>Model</th>
  <th>Operating System</th>
  <th>Received By</th>
  <th>Date Received</th>
  <th>Fault Description</th>
  <th>Password - Windows Admin</th>
  <th>Data Recovery?</th>
  <th>Power Supply?</th>
  <th>Job Status</th>
 </tr>
</thead>
<tbody>
<?php
}
while($row=mysql_fetch_array($result))
{
 echo "<tr>";
 
   echo '<td>' . $row['CUST_ID'] . '</td>';
   echo '<td>' . $row['CUST_Forename'] . '</td>';
   echo '<td>' . $row['CUST_Surname'] . '</td>';
   echo '<td>' . $row['CUST_Email'] . '</td>';
   echo '<td>' . $row['CUST_Mobile'] . '</td>';
   echo '<td>' . $row['CUST_HomeNum'] . '</td>';
   echo '<td>' . $row['CUST_AddressL1'] . '</td>';
   echo '<td>' . $row['CUST_AddressL2'] . '</td>';
   echo '<td>' . $row['CUST_AddressL3'] . '</td>';
   echo '<td>' . $row['CUST_Postcode'] . '</td>';
   echo '<td>' . $row['J_RefNum'] . '</td>';
   echo '<td>' . $row['MANU_Name'] . '</td>';
   echo '<td>' . $row['J_Model'] . '</td>';
   echo '<td>' . $row['OS_Name'] . '</td>';
   echo '<td>' . $row['J_ReceivedBy'] . '</td>';
   echo '<td>' . $row['J_DateRec'] . '</td>';
   echo '<td>' . $row['J_FaultDesc'] . '</td>';
   echo '<td>' . $row['J_PassWinAdmin'] . '</td>';
   echo '<td>' . $row['J_DataRecYN'] . '</td>';
   echo '<td>' . $row['J_PowerSuppYN'] . '</td>';
   echo '<td>' . $row['JS_Status'] . '</td>';
 
 
 echo "</tr>";
 
}

?>
</tbody>
</table>

 

Thanks Again


Viewing all articles
Browse latest Browse all 13200

Trending Articles