• 20-03-2015, 19:22:56
    #1
    Merhaba, fonksiyonumun içini mysql'den gelecek verilerle doldurma istiyorum. Nasıl mümkün olabilir acaba?

    $(function() {
    						
    							$('burası').avgrund({
    								width:burası,
    								height: 620,
    								holderClass: 'custom',
    								showClose: true,
    								onBlurContainer: '.container',
    								template: '<ul class="popup">'+
    								'<p>&nbsp;</p>'+
    								'<p>&nbsp;</p>'+
    								'<li class="resim">burası </li><li class="icerik2">'+
    								'<p>&nbsp;</p>'+
    								'<h2 class="bas1">burası </h2>'+
    								'<p>&nbsp;</p>'+
    								'<h2 class="bas2">burası</h2>'+ 
    								'<p>&nbsp;</p>'+
    								'<p class="yaz fontsize15">burası</p>'+
    								'</li>'+
    								'<p>&nbsp;</p>'+
    								'<li><button class="avgrund-close kpt" type="button"></button>  </li>'+
    							'</ul>'
    							});
  • 29-03-2015, 13:25:41
    #2
    güncel.
  • 31-03-2015, 13:46:23
    #3
    Selamlar TayCom,

    Sana lazim olan seyler...biraz daha zordur. Bu kadar basit degil.
    Aklima tek gelen yol simdilik: AJAX/jQuery ( zaten jquery kullaniyorsun simdi) ve PHP/mySQL olucak.

    Sana basit bir ornek gostericem:

    1) Ilk once veritabanin olmali. Tabiki vardir. Ben ornek olarak bunu alicam:


    2) Bir php komut dosyasıni oluşturup veritabanından verileri http requestleri ile almak. Tabiki kendi doğrulamalarinla. (mesela adini api.php koyalim)

    <?php 
    
      //--------------------------------------------------------------------------
      // Example php script for fetching data from mysql database
      //--------------------------------------------------------------------------
      $host = "localhost";
      $user = "root";
      $pass = "root";
    
      $databaseName = "ajax01";
      $tableName = "variables";
    
      //--------------------------------------------------------------------------
      // 1) Connect to mysql database
      //--------------------------------------------------------------------------
    
      $con = mysql_connect($host,$user,$pass);
      $dbs = mysql_select_db($databaseName, $con);
    
      //--------------------------------------------------------------------------
      // 2) Query database for data
      //--------------------------------------------------------------------------
      $result = mysql_query("SELECT * FROM $tableName");          //query
      $array = mysql_fetch_row($result);                          //fetch result    
    
      //--------------------------------------------------------------------------
      // 3) echo result as json 
      //--------------------------------------------------------------------------
      echo json_encode($array);
    
    ?>
    3) Ayni yerde, bit tane script client.php kuralim. Burda ise api.php-den JSON formatinda id ve name elemanlari alicak, ve sayfaya gostericek.

    <!---------------------------------------------------------------------------
    Example client script for JQUERY:AJAX -> PHP:MYSQL example
    ---------------------------------------------------------------------------->

    <html>
      <head>
        <script language="javascript" type="text/javascript" src="jquery.js"></script>
      </head>
      <body>
    
      <!-------------------------------------------------------------------------
      1) Create some html content that can be accessed by jquery
      -------------------------------------------------------------------------->
      <h2> Client example </h2>
      <h3>Output: </h3>
      <div id="output">this element will be accessed by jquery and this text replaced</div>
    
      <script id="source" language="javascript" type="text/javascript">
    
      $(function () 
      {
        //-----------------------------------------------------------------------
        // 2) Send a http request with AJAX http://api.jquery.com/jQuery.ajax/
        //-----------------------------------------------------------------------
        $.ajax({                                      
          url: 'api.php',                  //the script to call to get data          
          data: "",                        //you can insert url argumnets here to pass to api.php
                                           //for example "id=5&parent=6"
          dataType: 'json',                //data format      
          success: function(data)          //on recieve of reply
          {
            var id = data[0];              //get id
            var vname = data[1];           //get name
            //--------------------------------------------------------------------
            // 3) Update html content
            //--------------------------------------------------------------------
            $('#output').html("<b>id: </b>"+id+"<b> name: </b>"+vname); //Set output element html
            //recommend reading up on jquery selectors they are awesome 
            // http://api.jquery.com/category/selectors/
          } 
        });
      }); 
    
      </script>
      </body>
    </html>

    4) client.php girerek ne oldugunu gorebilirsin.
  • 02-04-2015, 02:34:57
    #4
    dbd adlı üyeden alıntı: mesajı görüntüle
    Selamlar TayCom,

    Sana lazim olan seyler...biraz daha zordur. Bu kadar basit degil.
    Aklima tek gelen yol simdilik: AJAX/jQuery ( zaten jquery kullaniyorsun simdi) ve PHP/mySQL olucak.

    Sana basit bir ornek gostericem:

    1) Ilk once veritabanin olmali. Tabiki vardir. Ben ornek olarak bunu alicam:


    2) Bir php komut dosyasıni oluşturup veritabanından verileri http requestleri ile almak. Tabiki kendi doğrulamalarinla. (mesela adini api.php koyalim)

    <?php 
    
      //--------------------------------------------------------------------------
      // Example php script for fetching data from mysql database
      //--------------------------------------------------------------------------
      $host = "localhost";
      $user = "root";
      $pass = "root";
    
      $databaseName = "ajax01";
      $tableName = "variables";
    
      //--------------------------------------------------------------------------
      // 1) Connect to mysql database
      //--------------------------------------------------------------------------
    
      $con = mysql_connect($host,$user,$pass);
      $dbs = mysql_select_db($databaseName, $con);
    
      //--------------------------------------------------------------------------
      // 2) Query database for data
      //--------------------------------------------------------------------------
      $result = mysql_query("SELECT * FROM $tableName");          //query
      $array = mysql_fetch_row($result);                          //fetch result    
    
      //--------------------------------------------------------------------------
      // 3) echo result as json 
      //--------------------------------------------------------------------------
      echo json_encode($array);
    
    ?>
    3) Ayni yerde, bit tane script client.php kuralim. Burda ise api.php-den JSON formatinda id ve name elemanlari alicak, ve sayfaya gostericek.

    <!---------------------------------------------------------------------------
    Example client script for JQUERY:AJAX -> PHP:MYSQL example
    ---------------------------------------------------------------------------->

    <html>
      <head>
        <script language="javascript" type="text/javascript" src="jquery.js"></script>
      </head>
      <body>
    
      <!-------------------------------------------------------------------------
      1) Create some html content that can be accessed by jquery
      -------------------------------------------------------------------------->
      <h2> Client example </h2>
      <h3>Output: </h3>
      <div id="output">this element will be accessed by jquery and this text replaced</div>
    
      <script id="source" language="javascript" type="text/javascript">
    
      $(function () 
      {
        //-----------------------------------------------------------------------
        // 2) Send a http request with AJAX http://api.jquery.com/jQuery.ajax/
        //-----------------------------------------------------------------------
        $.ajax({                                      
          url: 'api.php',                  //the script to call to get data          
          data: "",                        //you can insert url argumnets here to pass to api.php
                                           //for example "id=5&parent=6"
          dataType: 'json',                //data format      
          success: function(data)          //on recieve of reply
          {
            var id = data[0];              //get id
            var vname = data[1];           //get name
            //--------------------------------------------------------------------
            // 3) Update html content
            //--------------------------------------------------------------------
            $('#output').html("<b>id: </b>"+id+"<b> name: </b>"+vname); //Set output element html
            //recommend reading up on jquery selectors they are awesome 
            // http://api.jquery.com/category/selectors/
          } 
        });
      }); 
    
      </script>
      </body>
    </html>

    4) client.php girerek ne oldugunu gorebilirsin.
    Merhabalar hocam, biraz geç gördüm cevabınızı kusura bakmayın. Mantığı anladım. Uygulayıp sonucu yazacağım. Çok teşekkürler.