[Linux-programlama] Re: ajax+mysql+php

---------

[Linux-programlama] Re: ajax+mysql+php

From: Nuri Akman <nuri.akman_at_hazine.gov.tr>
Date: Tue, 04 Mar 2008 17:14:25 +0200
Message-ID: <47CD6751.5040304@hazine.gov.tr>

Merhaba,

onchange'e yazdığınız requestCustomerInfo() fonksiyonunu bir parametre
olmadan kullanıyorsunuz. Halbuki, Ekrana bir çok satır veri sıralamış
haldesiniz. O verinin ID'sini göndererek doğru satırdaki verilere
ulaşmalısınız.

Selamlar,
Nuri AKMAN

Uzman Celal Dikici yazmış:
> Merhabalar,
> Alttaki gibi bir update tablom var. Son index kolonunda değişiklik
> olunca ilgili table da ilgili kayıtı update etsin istiyorum. Dolayısı
> ile son index e onchange ekledim.Bunu mysql+php+ajax kullanarak
> yapıyorum. iki adet php dosyam var.Ajax(javascript) kodlarında bir
> yerde takılıyorum. function requestCustomerInfo() da. Program bu
> haliyle ben herhangi bir kayıt satırını düzeltsem de, for döngüsündeki
> en son deger olan 6 ıncı yı düzeltiyor.Ben ise düzeltme yaptığım
> satırı update etmek istiyorum.Düzeltme yaptığım kayıt satırını
> düzeltmesini nasıl sağlayabilirim acaba?
> Teşekkürler.
>
>
> *id*
>
>
>
> *lno*
>
>
>
> *ilk index*
>
>
>
> *son index*
>
>
>
> *fark*
>
> 1
>
>
>
> 1
>
>
>
> 2010
>
>
>
> 2015
>
>
>
> 5
>
> 2
>
>
>
> 2
>
>
>
> 2020
>
>
>
> 2025
>
>
>
> 5
>
> 3
>
>
>
> 3
>
>
>
> 2030
>
>
>
> 2035
>
>
>
> 5
>
> 4
>
>
>
> 4
>
>
>
> 2040
>
>
>
> 2045
>
>
>
> 5
>
> 5
>
>
>
> 5
>
>
>
> 2050
>
>
>
> 2055
>
>
>
> 5
>
> 6
>
>
>
> 6
>
>
>
> 2060
>
>
>
> 2065
>
>
>
> 5
>
> --------------------------------------------------------------------------------------
> # upd.php update yapacak dosyam.
> <?php
> $eidsrf=$_GET["eidsrf"];
> $lojmno=$_GET["lojmno"];
> $elek01=$_GET["elek01"];
> $farkii=$_GET["farkii"];
> $ucrytl=$_GET["ucrytl"];
> $updateSQL = sprintf("update e_elksrf set elek01=$elek01 where
> eidsrf=$eidsrf");
> mysql_select_db($database_gupp, $gupp);
> $Result1 = mysql_query($updateSQL, $gupp) or die(mysql_error());
> if ($Result1) echo "Duzeldi";
> else
> echo "Hata var";
> ?>
> --------------------------------------------------------------------------------------
>
> <?php
> #giris.php girisi yapacagim php dosyam
> # database e baglan
> require_once('Connections/gupp.php'); ?>
> <?php
> mysql_select_db($database_gupp, $gupp);
> $query_Recordset1 = "SELECT * FROM e_elksrf ORDER BY e_elksrf.lojmno";
> $Recordset1 = mysql_query($query_Recordset1, $gupp) or die(mysql_error());
> $row_Recordset1 = mysql_fetch_assoc($Recordset1);
> $totalRows_Recordset1 = mysql_num_rows($Recordset1);
> ?>
> <script type="text/javascript">
> var url = "upd.php?";
> function handleHttpResponse() {
> if (http.readyState == 4) {
> if(http.status==200) {
> var results=http.responseText;
> document.getElementById('div1234').innerHTML = results;
> } } }
> function requestCustomerInfo() {
> for (i = 1; i <=6; i++)
>
> var eidsrf = document.getElementById("eidsrf"+i).value;
> var elek01 = document.getElementById("elek01"+i).value;
> var lojmno = document.getElementById("lojmno"+i).value;
> var ucrytl = document.getElementById("ucrytl"+i).value;
> var farkii = document.getElementById("farkii"+i).value;
> degisken ="elek01=" + escape(elek01) + "&" + "eidsrf=" +
> escape(eidsrf) + "&" +"lojmno=" + escape(lojmno) + "&" + "ucrytl=" +
> escape(ucrytl) + "&" + "farkii=" + escape(farkii)
> //alert(degisken);
> http.open("GET", url + degisken, true);
> http.onreadystatechange = handleHttpResponse;
> http.send(null);
> }
> function getHTTPObject() {
> var xmlhttp;
> if(window.XMLHttpRequest){
> xmlhttp = new XMLHttpRequest();
> }
> else if (window.ActiveXObject){
> xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
> if (!xmlhttp){
> xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
> }
> }
> return xmlhttp;
> }
> var http = getHTTPObject(); // We create the HTTP Object
> </script>
> <head>
> <style type="text/css">
> <!--
> .style3 {
> font-family: Verdana, Arial, Helvetica, sans-serif;
> font-size: small;
> color: #FF0000;
> }
> .style6 {color: #FFFFFF}
> .style9 {
> font-family: Verdana, Arial, Helvetica, sans-serif;
> font-size: small;
> }
> .style11 {font-size: small}
> -->,
> </style>
> </head>
> <body>
> <table border="1" align="center" bordercolor="#AABBCC">
> <tr>
> <td><span class="style9">elektrik index girişi</span></td>
> <td>&nbsp;</td>
> </tr> <tr><td colspan="2">
> <?php
> do {
> ?>
> <table align="center"> <tr valign="baseline">
> <td>id<input name="eidsrf<?php echo $row_Recordset1['eidsrf']; ?>"
> id="eidsrf<?php echo $row_Recordset1['eidsrf']; ?>"
> type="text" value="<?php echo$row_Recordset1['eidsrf']; ?>" size="4"
> maxlength="6" /></td>
> <td>Lno<input name="lojmno<?php echo $row_Recordset1['eidsrf']; ?>"
> id="lojmno<?php echo $row_Recordset1['eidsrf']; ?>"
> type="text" value="<?php echo $row_Recordset1['lojmno']; ?>" size="4"
> maxlength="6" /></td>
> <td><div align="right">ilkindex<input type="text" name="oncyil_sonayi"
> value="<?php echo $row_Recordset1['oncyil_sonayi']; ?>" size="4"
> maxlength="6" /></div></td>
>
> <td>sonindex<input type="text" name="elek01<?php echo
> $row_Recordset1['eidsrf']; ?>" id="elek01<?php echo
> $row_Recordset1['eidsrf']; ?>" onChange="requestCustomerInfo()"
> value="<?php echo $row_Recordset1['elek01']; ?>" size="4"
> maxlength="6" /></td>
> <td>farkii<input type="text" name="farkii<?php echo
> $row_Recordset1['eidsrf']; ?>" id="farkii<?php echo
> $row_Recordset1['eidsrf']; ?>"
> value="<?php echo $row_Recordset1['farkii']; ?>" size="4"
> maxlength="6" /></td>
> <td>ucret <input type="text" name="ucrytl<?php echo
> $row_Recordset1['eidsrf']; ?>" id="ucrytl<?php echo
> $row_Recordset1['eidsrf']; ?>"
> value="<?php echo $row_Recordset1['ucrytl']; ?>" size="4"
> maxlength="6" /></td>
> </tr></table>
> <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
> </td> </tr></table>
> </td></tr></table>
> <div id="div1234"></div>
> </body>
> </html>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Linux-programlama mailing list
> Linux-programlama_at_liste.linux.org.tr
> http://liste.linux.org.tr/mailman/listinfo/linux-programlama

_______________________________________________
Linux-programlama mailing list
Linux-programlama_at_liste.linux.org.tr
http://liste.linux.org.tr/mailman/listinfo/linux-programlama
Received on Tue 04 Mar 2008 - 16:34:27 EET

---------

Bu arsiv hypermail 2.2.0 tarafindan uretilmistir.