• 01-02-2016, 15:28:23
    #1
    arkadaşlar,

    aşağıdaki kodu asp ye nasıl çevirebiliriz.

    <?php
    require_once 'config.php';
    if(!empty($_POST['type'])){
    	$type = $_POST['type'];
    	$name = $_POST['name_startsWith'];
    	$query = "SELECT productCode, productName, buyPrice FROM products where quantityInStock !=0 and UPPER($type) LIKE '".strtoupper($name)."%'";
    	$result = mysqli_query($con, $query);
    	$data = array();
    	while ($row = mysqli_fetch_assoc($result)) {
    		$name = $row['productCode'].'|'.$row['productName'].'|'.$row['buyPrice'];
    		array_push($data, $name);
    	}	
    	echo json_encode($data);exit;
    }
    ?>
  • 04-02-2016, 02:12:49
    #2
    tam çalışırmı bilmem aşağıda bişeyler karaladım

    ancak asp de ki array sistemi php deki gibi değil,tam olarak nasıl bih tiyaç olduğunu f,*** bilmediğim için o kısımları es geçtim. veri tabanında veriyi alır ve dediğiniz sırada ekrana listeler
    json_encode komutu sanırım şu ağaç şeklinde liste veren komuttu,öyle ise o komut doğrudan asp de yok(en azından ben bilmiyorum).belki özel fonksiyon yada class şeklinde olabilir google bakınız

    config.asp dosyanız
    Set Baglanti = Server.CreateObject("adodb.connection")
    Baglanti.Open = "driver={mysql odbc 3.51 driver}; server=localhost; UID=xxxxxxx; pwd=xxxxxx; db=xxxxx; port=3306;"
    
    Baglanti.Execute "SET NAMES 'latin5'"
    Baglanti.Execute "SET CHARACTER SET latin5"
    Baglanti.Execute "SET COLLATION_CONNECTION = 'latin5_turkish_ci'"
    son 3 satır şart mı emin değilim,elimdeki sitede vardı

    sorudaki sayfanız
    <!--#include file="inc/config.asp"-->
    <%
    if request.form("type")<>"" then
    
        tipi = $_POST['type']; 
        name = $_POST['name_startsWith']; 
        query = "SELECT productCode, productName, buyPrice FROM products where quantityInStock !=0 and UPPER(" & tipi & ") LIKE '" & ucase(name) & "%'"; 
        set result = baglanti.execute(query); 
    
    
    do while not result.eof
           isim=result("productCode")& "|" &result("productName")& "|" &result("buyPrice")
            response.write isim&<br>'bu satır sizin verdiğiniz örnekte yok ama
           result.movenext
    loop
    
    end if
    %>