ajax array php

0 favourites
  • 12 posts
From the Asset Store
Paypal PHP Supports multiple platforms, Web/html5 Android, IOS. (Including storing transaction data)
  • Guys, help ? There are online databases. As can be realized through the Ajax a chip that for each row from the database to create items in the ListBox C2 c columns of data?

    Those. how to make the right script and how to handle the Ajax response?

    All the catch is that initially only known variables A, B, C. Accordingly, you need to at the touch of a button the request was sent to the database, and received a response from the figures in response made to the ListBox. In response Ajax - an array of JSON, but I can not load the array into the project, and the more processed.

  • any ideas?

  • a couple of question did you import the files for ajax to get the files from ? and can you not use rex csv to array for this very same function since his is like the exact thing you are trying to do and it build the array through imported excel files.

  • no-no.

    you missed thing.

    i have an online SQL DataBase. And i need to import all table data in some rows into c2 project as listbox items.

    a little explaine - i have such rows as UserName and his contact. so i want to import this data into project on construct2 as listbox items. for each tabledata (userName and UserContact) separate listbox item.

    Can anyone help me with it?

  • p.s. i don't request any files from my server. all i need - is just request table data from table rows from online SQL DataBase, fetch an array of it, convert as json, recieve this as AJAX.LastData, push it into array in project and for each xy add a lie to list box with array.y-text.

    i need a correct php script, which will make it happens

  • up

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • i have an online SQL DataBase. And i need to import all table data in some rows into c2 project as listbox items.

    a little explaine - i have such rows as UserName and his contact. so i want to import this data into project on construct2 as listbox items. for each tabledata (userName and UserContact) separate listbox item.

    maybe you can use CSV instead JSON...

    Persons table (userName; userContact)

    PHP file

    <?php
    $servername = "yourServerName.com";
    $username = "yourUserName";
    $password = "yourPassword";
    $dbname = "yourDatabaseName";
    
    // Create connection
    $conn = new mysqli($servername, $username, $password, $dbname);
    // Check connection
    if ($conn->connect_error) {
        die("Connection failed: " . $conn->connect_error);
    } 
    
    $sql = "SELECT  userName, userContact FROM Persons";
    $result = $conn->query($sql);
    
    if ($result->num_rows > 0) {
        // output data of each row
        while($row = $result->fetch_assoc()) {
            echo  $row["userName"]. "#" . $row["userContact"] . PHP_EOL; 
        }
    } else {
        echo "0 results";
    }
    $conn->close();
    exit;
    ?>[/code:3cm5v3t1]
    
    [url=https://www.scirra.com/forum/plugin-csv-csv2array-csv2dictionary_t64326]CSV2Array Plugin[/url]
    
    [img="http://lookpic.com/O/i2/1992/B5uX7V1Y.png"]
    
    [url=https://app.box.com/s/230lpj02kzbtikkq08bx5bjg5wh89ssy]dataCSV2Array.capx[/url]
  • Thanx man! Guess, i can use it for a while. But it's not exactly what i'm looking for. =/

  • Json to Array

    Persons table (userName; userContact)

    PHP file

    <?php
    $servername = "yourServerName.com";
    $username = "yourUserName";
    $password = "yourPassword";
    $dbname = "yourDatabaseName";
    
    $conn = new mysqli($servername, $username, $password, $dbname);
    if ($conn->connect_error) {
        die("Connection failed: " . $conn->connect_error);
    } 
    
    $size = array(4,2,1);
    
    $sql = "SELECT  userName, userContact FROM Persons";
    $result = $conn->query($sql);
    
    $response = array(
        "c2array" => true,
        "size" => $size,
        "data" => array()
    );
    
    while ( $row = $result->fetch_assoc() ) {
        $response['data'][] = array(
            array($row['userName']),
            array($row['userContact'])
        );
    }
    
    echo json_encode($response);
    $conn->close();
    exit();
    ?>[/code:26n3mbpf]
    [img="http://oi63.tinypic.com/71tn2u.jpg"]
    
    [url=https://app.box.com/s/8r2wgcc1by9il8tumqbw29x3suk9lfll]jsonPHP2Array.capx[/url]
  • Bro! YOU ARE THE GREATEST!!!!

    Thank you very-very much!!!

    It's that i'm looking for =))))

    Haw i can up you reputation? Can't see any button =/

  • one question.

    if i have another count of table rows, how i must change array size? i mean, on which parameters does array size is based?

    4 - width ? (meaning 4 table rows?)

    2 - height ? (what does it mean?)

    1-depth ? (what for?)

    is it 2d or 3d array?

  • Array

    Array properties

    Width (X dimension)

    Height (Y dimension)

    Depth (Z dimension)

    The size of the array. If you want a one-dimensional array (i.e. a list of values), use A x 1 x 1. If you want a two-dimensional array (i.e. a grid of values) use A x B x 1.

    in c2 is necessary to determine all three dimensions

    ....................

    Table Persons

    C2 Array

    so..PHP script transform Rows to Columns & columns2rows..

    $size = array(4,2,1);[/code:2clsnhon]
    in this case
    [b]$size = array(Rows[/b](4)[b],Columns[/b](userName&userContact)[b],1);[/b]
    
    php script to check [b]$size[/b]
    [code:2clsnhon]<?php
    $servername = "yourServerName.com";
    $username = "yourUserName";
    $password = "yourPassword";
    $dbname = "yourDatabaseName";
    
    $conn = new mysqli($servername, $username, $password, $dbname);
    
            if ($conn->connect_error) 
    		  {
            die("Connection failed: " . $conn->connect_error);
              } 
    
    $sql="SELECT * FROM Persons ";
    
    if ($result=mysqli_query($conn,$sql))
      {
      
      $rowcount=mysqli_num_rows($result);
      $columncount=mysqli_num_fields($result);
                $size=( 'array('.$rowcount. ',' .$columncount.',1)' ) ;
                echo($size);
     
                mysqli_free_result($result);
      }
    
    mysqli_close($conn);
    exit();
    ?>[/code:2clsnhon]
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)