@KeremWho;
@yusuf68700;
Hocalarım bir demo yaptım bakabilir misiniz? Ben denemeler yaptım fakat tabloya bir türlü alt alta yazamadım kafam çok karıştı sonuca ulaşamadım bir türlü.
Değerleri tabloya yazdırıyorum fakat hep aynıları dönüyor.
<form id="contactForm1" action="http://localhost/array.php" method="post">
<input type="text" name="Kod[]" value="01"> <br>
<input type="text" name="Cinsi[]" value="Köşelik"> <br>
<input type="text" name="Fiyat[]" value="1.5"> <br>
<hr>
<input type="text" name="Kod[]" value="02"> <br>
<input type="text" name="Cinsi[]" value="Perde"> <br>
<input type="text" name="Fiyat[]" value="1.2"> <br>
<hr>
<input type="text" name="Kod[]" value="03"> <br>
<input type="text" name="Cinsi[]" value="Tabure"> <br>
<input type="text" name="Fiyat[]" value="1.1"> <br>
<button type="submit" style="margin-top: 15px;">Yolla</button>
</form>
<script type="text/javascript">
var frm = $('#contactForm1');
frm.submit(function(e) {
e.preventDefault();
$.ajax({
type: frm.attr('method'),
url: frm.attr('action'),
data: frm.serialize(),
success: function(data) {
console.log('Basarili');
console.log(data);
},
error: function(data) {
console.log('Hata');
console.log(data);
},
});
});
</script>
<?php print_r($_POST); ?>
<style>
table,
td,
th {
border: 1px solid black;
}
table {
width: 100%;
border-collapse: collapse;
}
</style>
<table>
<tr>
<th>Kod</th>
<th>Cinsi</th>
<th>Fiyat</th>
</tr>
<?php foreach ($_POST as $key => $value) { ?>
<tr>
<td><?= $value[2]; ?></td>
<td><?= $value[2]; ?></td>
<td><?= $value[2]; ?></td>
</tr>
<?php } ?>
</table>