Merhabalar.
Excelde 12 sütunda yani 12 tane veri var, ve 3000 satır yani 3000 adet hayvanımızın yaşam verileri bulunuyor.
Bu veriler günde 1-2 kere değişiyor.
Ben bu excel verim ile en basitinden nasıl bir sorgu oluşturabilirim. sql mi olur php mi olur en kolayı nedir.
Örnek ben 1234 küpe numarasını girdiğimde bana bu küpe numaranın 11 adet verisini verecek. Bunun en kolay nedir size göre bana nasıl yardımcı olabilirsiniz.
<?php
// Config
$csvFile = 'hayvanlar.csv';
if(isset($_POST['kupe_no'])) {
$kupeNo = $_POST['kupe_no'];
$bulundu = false;
if (($handle = fopen($csvFile, "r")) !== FALSE) {
// Başlık satırını oku
$basliklar = fgetcsv($handle, 1000, ",");
while (($veri = fgetcsv($handle, 1000, ",")) !== FALSE) {
if($veri[0] == $kupeNo) {
$bulundu = true;
break;
}
}
fclose($handle);
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Hayvan Veri Sorgulama</title>
<meta charset="utf-8">
<style>
body { font-family: Arial; margin: 20px; }
.sonuc { margin-top: 20px; border: 1px solid #ddd; padding: 15px; }
</style>
</head>
<body>
<h2>Hayvan Veri Sorgulama</h2>
<form method="post" action="">
<label for="kupe_no">Küpe Numarası:</label>
<input type="text" name="kupe_no" id="kupe_no" required>
<button type="submit">Sorgula</button>
</form>
<?php if(isset($bulundu) && $bulundu): ?>
<div class="sonuc">
<h3><?php echo $kupeNo; ?> numaralı hayvan bilgileri:</h3>
<table border="1" cellpadding="5">
<tr>
<?php foreach($basliklar as $baslik): ?>
<th><?php echo $baslik; ?></th>
<?php endforeach; ?>
</tr>
<tr>
<?php foreach($veri as $deger): ?>
<td><?php echo $deger; ?></td>
<?php endforeach; ?>
</tr>
</table>
</div>
<?php elseif(isset($bulundu)): ?>
<div class="sonuc">
<p>Küpe numarası bulunamadı!</p>
</div>
<?php endif; ?>
</body>
</html>Excel dosyasını aynı dizinde csv olarak çıkartıp php dosyasını çalıştırın hocam en basit yöntem bu olur