<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">   
 <html xmlns="http://www.w3.org/1999/xhtml">   
 <head>   
 <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />   
 <title>Preview File CSV</title>   
 </head>   
   
 <body>   
 <h1>Preview File CSV</h1>  
 <?php  
 if(isset($_POST['UPLOAD']))  
 {  
 if ($_FILES['csv']['size'] > 0) {   
    $file = $_FILES['csv']['tmp_name'];   
   $handle = fopen($file,"r");   
   $data = fgetcsv($handle,318,",","'");  
   $step=1;   
   
 ?>  
 <form action="insert.php" method="POST" enctype="multipart/form-data" name="form1" id="form1">   
 <?php  
 echo "  
 <table border=0>  
 <tr>  
		<th><center>No</th>
		<th><center>STATUS EKONOMI</th>
		<th><center>PENDIDIKAN</th>
        <th><center>TANGGUNGAN</th>
        <th><center>JENIS USAHA</th> 
		<th><center>PENDAPATAN</th>
		
		 
		
		
 </tr>";  
   do {   
     if (count($data)==5) {  
         if($data[4])  
         {   
 echo "<tr>";  
 echo "<td align=center>".$step."</td>";  
 
 echo "<td><input type='text' name='yt".$step."' value='".$data[0]."'/></td>"; 
 echo "<td><input type='text' name='x1".$step."' value='".$data[1]."'/></td>";  
 echo "<td><input type='text' name='x2".$step."' value='".$data[2]."'/></td>";  
 echo "<td><input type='text' name='x3".$step."' value='".$data[3]."'/></td>";  
  echo "<td><input type='text' name='x4".$step."' value='".$data[4]."'/></td>";  
   
  
 echo "</tr>";  
 $step++;}  
     }  
     else echo "ERROR! jumlah field tidak sesuai<br/>";   
   } while ($data = fgetcsv($handle,318,",","'"));   
 }   
 }  
 echo "<tr>";  
 echo "<td colspan='5' align='right'><font color='blue'>JUMLAH DATA = </font><input type='text' name='count' value='".($step-1)."'/></td>";  
 echo "</tr>";  
 ?>   
 <tr>  
 <td colspan=4><b><font color=red>PASTIKAN DATA SUDAH BENAR BARU TZamaludin ArsyadN ENTER</font></b></td>  
 <td><input type='submit' name='enter' value='Enter'/></td>  
 </tr>  
 </table>  
 </form>  
 </body>  
 </html>  
