Postingan lainnya
Table-Row tidak tercetak di PHP
Permisi teman2 , saya baru di kelas koding ini . saya coba coba buat aplikasi sederhana . dengan koneksi menggunakan MS SQL server alias ODBC ,karena perusahaan saya menggunakan SQL server dan VB.net saya coba sudah terkoneksi tapi masalahnya adalah datanya saat ditampilkan jadi acak acakkan . mohon bantuannya . saya sertakan code nya
Thanks ,
<!DOCTYPE html>
<html>
<head>
<title> Simple</title>
</head>
<body>
<center>
<form action="tampilgiromix.php" method="get">
List Mesin : <br>
<select>
<option value="Extruder"> Extruder</option>
<option value="complex">Inner Complex</option>
<option value="calendar">Calendar</option>
</select> <br><br>
Start Date : <br>
<input type="text" placeholder="yyyy/mm/dd" name="tglawal"><br>
End date : <br>
<input type="text" placeholder="yyyy/mm/dd" name="tglakhir"><br><br>
<input type="submit" name="submit">
</form> <br>
</center>
</body>
</html>
<?php include 'connection.php'; ?>
<?php
if(isset($_GET['tglawal']) && isset($_GET['tglakhir'])){
$dari = $_GET['tglawal'];
$sampai = $_GET['tglakhir'];
?>
<table border ="1" >
<tr>
<th >No</th>
<th >Plant</th>
<th >Machines Code</th>
<th >Calculation Date</th>
<th >PP Code</th>
<th >SFC Code Code</th>
<th >ST Code</th>
<th >Value 1</th>
<th >Value 2</th>
<th >Change Count</th>
<th >Distinct Count</th>
<th >Factory</th>
</tr>
<?php
// mengambil data pelanggan dari database
$data = odbc_exec($koneksi,"select top 1000 * from [PCSRepository].[dbo].dc_giromix where PLANT ='ID' and MCH_CODE ='TRI1' and CALC_DATE >= '2018/10/1' and CALC_DATE <= '2018/10/13'");
$no = 1;
// mengubah data ke array dan menampilkannya dengan perulangan while
while($d=odbc_fetch_array($data)){
?>
<tr>
<th ><?php echo $no++; ?></th>
<td><?php echo $d['MCH_CODE']; ?></td>
<td><?php echo $d['CALC_DATE']; ?></td>
<td><?php echo $d['PP_CODE']; ?></td>
<td><?php echo $d['SFC_CODE']; ?></td>
<td><?php echo $d['ST_CODE']; ?></td>
<td><?php echo $d['VAL1']; ?></td>
<td><?php echo $d['VAL2']; ?></td>
<td><?php echo $d['CHANGE_COUNT']; ?></td>
<td><?php echo $d['DISTINCT_COUNT']; ?></td>
<td><?php echo $d['FACTORY']; ?></td>
</tr>
</table>
<?php
}
}
?>
3 Jawaban:
Jawaban Terpilih
karena tag </table> di dalam for, coba ini <pre> <!DOCTYPE html> <html> <head> <title> Simple</title> </head> <body>
<center> <form action="tampilgiromix.php" method="get"> List Mesin : <br> <select> <option value="Extruder"> Extruder</option> <option value="complex">Inner Complex</option> <option value="calendar">Calendar</option> </select> <br><br> Start Date : <br> <input type="text" placeholder="yyyy/mm/dd" name="tglawal"><br> End date : <br> <input type="text" placeholder="yyyy/mm/dd" name="tglakhir"><br><br> <input type="submit" name="submit">
&lt;/form&gt; &lt;br&gt;
</center>
</body> </html>
<?php include 'connection.php'; ?>
<?php if(isset($_GET['tglawal']) && isset($_GET['tglakhir'])){
$dari = $_GET['tglawal'];
$sampai = $_GET['tglakhir'];
?>
<table border ="1" >
&lt;tr&gt;
&lt;th &gt;No&lt;/th&gt;
&lt;th &gt;Plant&lt;/th&gt;
&lt;th &gt;Machines Code&lt;/th&gt;
&lt;th &gt;Calculation Date&lt;/th&gt;
&lt;th &gt;PP Code&lt;/th&gt;
&lt;th &gt;SFC Code Code&lt;/th&gt;
&lt;th &gt;ST Code&lt;/th&gt;
&lt;th &gt;Value 1&lt;/th&gt;
&lt;th &gt;Value 2&lt;/th&gt;
&lt;th &gt;Change Count&lt;/th&gt;
&lt;th &gt;Distinct Count&lt;/th&gt;
&lt;th &gt;Factory&lt;/th&gt;
&lt;/tr&gt;
&lt;?php
// mengambil data pelanggan dari database
$data = odbc_exec($koneksi,"select top 1000 * from [PCSRepository].[dbo].dc_giromix where PLANT ='ID' and MCH_CODE ='TRI1' and CALC_DATE &gt;= '2018/10/1' and CALC_DATE &lt;= '2018/10/13'");
$no = 1;
// mengubah data ke array dan menampilkannya dengan perulangan while while($d=odbc_fetch_array($data)){
?>
&lt;tr&gt;
&lt;th &gt;&lt;?php echo $no++; ?&gt;&lt;/th&gt;
&lt;td&gt;&lt;?php echo $d['MCH_CODE']; ?&gt;&lt;/td&gt;
&lt;td&gt;&lt;?php echo $d['CALC_DATE']; ?&gt;&lt;/td&gt;
&lt;td&gt;&lt;?php echo $d['PP_CODE']; ?&gt;&lt;/td&gt;
&lt;td&gt;&lt;?php echo $d['SFC_CODE']; ?&gt;&lt;/td&gt;
&lt;td&gt;&lt;?php echo $d['ST_CODE']; ?&gt;&lt;/td&gt;
&lt;td&gt;&lt;?php echo $d['VAL1']; ?&gt;&lt;/td&gt;
&lt;td&gt;&lt;?php echo $d['VAL2']; ?&gt;&lt;/td&gt;
&lt;td&gt;&lt;?php echo $d['CHANGE_COUNT']; ?&gt;&lt;/td&gt;
&lt;td&gt;&lt;?php echo $d['DISTINCT_COUNT']; ?&gt;&lt;/td&gt;
&lt;td&gt;&lt;?php echo $d['FACTORY']; ?&gt;&lt;/td&gt;
&lt;/tr&gt;
<?php
}
?>
</table>
<?php
}
?>
</pre>
Oke mas Thanks ya .. ternyata kurang teliti saya .