Codeigniter ile veritabanında aritmetik işlemler

Web tabanlı uygulama geliştirme araçları(PHP, ASP vb...) ile ilgili konuları buraya yazabilirsiniz.
Cevapla
sozgur
Üye
Mesajlar: 59
Kayıt: 26 Ağu 2011 09:52

Codeigniter ile veritabanında aritmetik işlemler

Mesaj gönderen sozgur »

Merhabalar, codeigniter frameworkunu öğrenmeye çalışıyorum ve yaptığım projede iki takımın da verilerini veritabanından çekebiliyorum. Ajax ile lig combosundan ligi seçtiğimde veritabanından o ligin takımları geliyor. daha sonra takımları seçtiğimde veritabanındaki sonuc alanından da attıkları basketleri alanlara getiriyorum (ajax ile) fakat bu çektiğim sonuçlar üzerinde henüz view alanlarına göndermeden toplama vs işlemler yapmak istiyorum. Bir türlü başaramadım. Çok basit muhtemelen ama çektiğim sonuçları değişkenlere atayarak birbirleriyle işlem yaptıramıyorum :( Yardımcı olursanız çok sevinirim. Herkese iyi çalışmalar.

model sayfası

Kod: Tümünü seç

<?php

Class Sonuc_goster_model extends CI_Model{

	
	function sonuclarev()
	{

		$ide=$_POST['ide'];
		$this->db->select('*');
		$this->db->from('takimlar');
		$this->db->where('takim_id', $ide);
		$takim_query = $this->db->get();

		return $takim_query->result();

	}


	function sonuclardep()
	{

		$idd=$_POST['idd'];
		$this->db->select('*');
		$this->db->from('takimlar');
		$this->db->where('takim_id', $idd);
		$takim_query = $this->db->get();

		return $takim_query->result();

	}

}

?>

controller sayfası

Kod: Tümünü seç

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

Class Sonuc_goster_controller extends CI_Controller 
{

	function evsahibi()
		{
			
			$this->load->model("sonuc_goster_model");
			$sonuc_listesiev = $this->sonuc_goster_model->sonuclarev();

				foreach($sonuc_listesiev AS $sonucse)
				{
					echo $sonucse->sonuc;
				}
	
		}


	function deplasman()
		{
			
			$this->load->model("sonuc_goster_model");
			$sonuc_listesidep = $this->sonuc_goster_model->sonuclardep();

				foreach($sonuc_listesidep AS $sonucsd)
				{
					echo $sonucsd->sonuc;
				}
	
		}
}
view sayfası

Kod: Tümünü seç

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
?><!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<title>Sonuç Görüntüle</title>
	<link href="<?php echo base_url();?>/css/Untitled1.css" rel="stylesheet" type="text/css">
	<link href="<?php echo base_url();?>/css/index.css" rel="stylesheet" type="text/css">
	<script src="<?php echo base_url();?>/js/jquery-1.10.1.min.js"></script>

	

</head>
<body>
	
<select name="sonuc_goster_ligler_cmb" size="1" id="lig_combo_sonuc_goster" style="position:absolute;left:293px;top:185px;width:121px;height:21px;z-index:0;">
	<option value="0" selected="selected">Lig Seçiniz...</option>
	<?php
		foreach($ligler_array as $ligs)
		{
		?>
		<option value="<?php echo $ligs['lig_id']; ?>"><?php echo $ligs['lig_adi']; ?></option>
		<?php	
		}
		?>
	?>
</select>
<!-- LIGLER SELECTI	- SONUC GOSTER -->

<!-- SONUC GOSTER EV SAHIBI -->
<select id="sonuc_goster_deplasman" class="sonuc_goster_takimlar" name="sonuc_goster_deplasman_cmb" size="1" id="deplasman_combo_sonuc_goster" style="position:absolute;left:372px;top:251px;width:121px;height:21px;z-index:2;">
	<option  selected="selected">Deplasman</option>
</select>

<!-- SONUC GOSTER DEPLASMAN -->
<select id="sonuc_goster_ev_sahibi" class="sonuc_goster_takimlar" name="sonuc_goster_ev_sahibi_cmb" size="1" id="ev_sahibi_combo_sonuc_goster" style="position:absolute;left:205px;top:251px;width:121px;height:21px;z-index:3;">
	<option  selected="selected">Ev Sahibi</option>
</select>


<div id="wb_Text1" style="position:absolute;left:305px;top:161px;width:99px;height:16px;text-align:center;z-index:4;">
<span style="color:#000000;font-family:Arial;font-size:13px;">Lig Seçiniz</span></div>
<div id="wb_Text2" style="position:absolute;left:372px;top:227px;width:121px;height:16px;text-align:center;z-index:5;">
<span style="color:#000000;font-family:Arial;font-size:13px;">Deplasman Takımı</span></div>
<div id="wb_Text3" style="position:absolute;left:205px;top:227px;width:121px;height:16px;text-align:center;z-index:6;">
<span style="color:#000000;font-family:Arial;font-size:13px;">Ev Sahibi Takım</span></div>
<div id="PageFooter1" style="position:absolute;overflow:hidden;text-align:left;left:0px;top:900px;width:100%;height:100px;z-index:7;">
</div>
<div id="wb_Text4" style="position:absolute;left:296px;top:129px;width:108px;height:32px;text-align:center;z-index:8;">
<span style="color:#000000;font-family:Arial;font-size:13px;"><strong>SONUÇ GÖSTER</strong></span></div>
<div id="wb_Text5" style="position:absolute;left:934px;top:161px;width:99px;height:16px;text-align:center;z-index:9;">
<span style="color:#000000;font-family:Arial;font-size:13px;">Lig Seçiniz</span></div>
<div id="wb_Text6" style="position:absolute;left:1012px;top:227px;width:121px;height:16px;text-align:center;z-index:10;">
<span style="color:#000000;font-family:Arial;font-size:13px;">Deplasman Takımı</span></div>
<div id="wb_Text7" style="position:absolute;left:833px;top:227px;width:121px;height:16px;text-align:center;z-index:11;">
<span style="color:#000000;font-family:Arial;font-size:13px;">Ev Sahibi Takım</span></div>
<div id="wb_Text8" style="position:absolute;left:925px;top:129px;width:108px;height:16px;text-align:center;z-index:12;">
<span style="color:#000000;font-family:Arial;font-size:13px;"><strong>SONUÇ GİRİŞ</strong></span></div>
<div id="wb_Text9" style="position:absolute;left:921px;top:288px;width:121px;height:16px;text-align:center;z-index:13;">
<span style="color:#000000;font-family:Arial;font-size:13px;">İlk Yarı Sonucu</span></div>
<div id="wb_Text10" style="position:absolute;left:921px;top:349px;width:121px;height:16px;text-align:center;z-index:14;">
<span style="color:#000000;font-family:Arial;font-size:13px;">İkinci Yarı Sonucu</span></div>
<input type="checkbox" id="sonuc_guven_chkbx" name="sonuc_guven_chkbx" value="on" style="position:absolute;left:1020px;top:422px;z-index:15;">
<div id="wb_Text11" style="position:absolute;left:909px;top:426px;width:121px;height:16px;text-align:center;z-index:16;">
<span style="color:#000000;font-family:Arial;font-size:13px;">Güvenilir Sonuç</span></div>
<input type="text" id="ev_iy_atti" style="position:absolute;left:940px;top:312px;width:28px;height:19px;line-height:19px;z-index:17;" name="ev_iy_atti" value="">
<div id="wb_ev_basket_lbl" style="position:absolute;left:280px;top:343px;width:55px;height:37px;text-align:center;z-index:18;">


<!-- EV SAHİBİ SPAN -->
<div id="ev_sahibi_sonuc" style="color:red;font-family:Arial;font-size:32px;"><strong></strong></div></div>
<!-- EV SAHİBİ SPAN -->

<!--<input type="button" id="sonuc_goster_btn" name="sonuc_goster_btn" value="Göster" style="position:absolute;left:296px;top:299px;width:96px;height:25px;z-index:19;">-->
<input type="submit" id="sonuc_kaydet_btn" name="sonuc_kaydet_btn" value="Kaydet" style="position:absolute;left:934px;top:469px;width:96px;height:25px;z-index:20;">
<div id="wb_dep_basket_lbl" style="position:absolute;left:349px;top:343px;width:55px;height:37px;text-align:center;z-index:21;">

<!-- DEPLASMAN SPAN -->
<div id="deplasman_sonuc" style="color:red;font-family:Arial;font-size:32px;"><strong></strong></div></div>
<!-- DEPLASMAN SPAN -->

<div id="wb_guven_lbl" style="position:absolute;left:296px;top:401px;width:96px;height:19px;text-align:center;z-index:22;">
<span style="color:#000000;font-family:Arial;font-size:15px;"><strong>GÜVENİLİR</strong></span></div>
<input type="text" id="dep_iy_atti" style="position:absolute;left:990px;top:312px;width:28px;height:19px;line-height:19px;z-index:23;" name="dep_iy_atti" value="">
<input type="text" id="ev_ms_atti" style="position:absolute;left:940px;top:370px;width:28px;height:19px;line-height:19px;z-index:24;" name="ev_ms_atti" value="">
<input type="text" id="ev_ms_atti" style="position:absolute;left:990px;top:370px;width:28px;height:19px;line-height:19px;z-index:25;" name="ev_ms_atti" value="">

<!-- LIGLER SELECTI	- SONUC GIRIS -->
<select name="sonuc_giris_ligler_cmb" size="1" id="lig_combo_sonuc_giris" style="position:absolute;left:922px;top:185px;width:121px;height:21px;z-index:26;">
	<option value="0" selected="selected">Lig Seçiniz...</option>
	<?php
		foreach($ligler_array as $ligs)
		{
		?>
		<option value="<?php echo $ligs['lig_id']; ?>"><?php echo $ligs['lig_adi']; ?></option>
		<?php	
		}
		?>
	?>
</select>
<!-- LIGLER SELECTI	- SONUC GIRIS -->
<select class="sonuc_giris_takimlar" name="sonuc_giris_ev_sahibi_cmb" size="1" id="ev_sahibi_combo_sonuc_giris" style="position:absolute;left:833px;top:251px;width:121px;height:21px;z-index:27;">
	<option selected="selected">Ev Sahibi</option>
	
</select>
<select class="sonuc_giris_takimlar" name="sonuc_giris_deplasman_cmb" size="1" id="deplasman_combo_sonuc_giris" style="position:absolute;left:1012px;top:251px;width:121px;height:21px;z-index:28;">
	<option  selected="selected">Deplasman</option>
</select>









<!-- SCRIPTS AREA -->

	<!-- SONUC GOSTER TAKIM SELECTLERI -->
	<script>
		$(document).ready(function(){
			$("#lig_combo_sonuc_goster").change(function(){
				var id=$(this).val();
				var dataString = 'id='+ id;
				$.ajax({
					type: "POST",
					url: "<?php echo base_url(); ?>" + "index.php/takimlari_cek_controller/index",
					data: dataString,
					cache: false,
					success: function(msg)
					{
					//alert('ok');
					//$('body').html(msg);
					$('.sonuc_goster_takimlar').html(msg);
					},
					error: function() { 
					alert('Hata oldu'); 
					} 
				});
			});
		});
	</script>

	<!-- SONUC GIRIS TAKIM SELECTLERI -->
	<script>
		$(document).ready(function(){
			$("#lig_combo_sonuc_giris").change(function(){
				var id=$(this).val();
				var dataString = 'id='+ id;
				$.ajax({
					type: "POST",
					url: "<?php echo base_url(); ?>" + "index.php/takimlari_cek_controller/index",
					data: dataString,
					cache: false,
					success: function(msg)
					{
					//alert('ok');
					//$('body').html(msg);
					$('.sonuc_giris_takimlar').html(msg);
					},
					error: function() { 
					alert('Hata oldu'); 
					} 
				});
			});
		});
	</script>

	<!-- SONUC GOSTER SONUCLAR EVSAHIBI-->
	<script>
		$(document).ready(function(){
			$("#sonuc_goster_ev_sahibi").change(function(){
				var id=$(this).val();
				var dataString = 'ide='+ id;
				$.ajax({
					type: "POST",
					url: "<?php echo base_url(); ?>" + "index.php/sonuc_goster_controller/evsahibi",
					data: dataString,
					cache: false,
					success: function(msg)
					{
					//alert('ok');
					//$('body').html(msg);
					$('#ev_sahibi_sonuc').html(msg);
					},
					error: function() { 
					alert("Hata Oluştu"); 
					} 
				});
			});
		});
	</script>

	<!-- SONUC GOSTER SONUCLAR DEPLASMAN-->
	<script>
		$(document).ready(function(){
			$("#sonuc_goster_deplasman").change(function(){
				var id=$(this).val();
				var dataString = 'idd='+ id;
				$.ajax({
					type: "POST",
					url: "<?php echo base_url(); ?>" + "index.php/sonuc_goster_controller/deplasman",
					data: dataString,
					cache: false,
					success: function(msg)
					{
					//alert('ok');
					//$('body').html(msg);
					$('#deplasman_sonuc').html(msg);
					},
					error: function() { 
					alert("Hata Oluştu"); 
					} 
				});
			});
		});
	</script>


</body>
</html>
Cevapla