ozkr's Recent Forum Activity

  • What is the way to get 2 fields from Mysql database into an array?

    Is my array format correct?

    {"c2array":true,"size":[7,1,1],"data":[["2","test"],["3","Oscar"],["4","Oscar"],["5","test"],["6","test"],["7","oscar"],["8","Oscar"]]}
    [/code:3jkdgoc4]
    Thanks in advance!
  • Hi,

    I just found the solution

    $result=mysqli_query($con, $sql);
    
    		$emparray = array();
    		// Start looping rows in mysql database.
    		while($rows=mysqli_fetch_assoc($result)){
    			$emparray[] = $rows;
    		// close while loop 
    		}
    		//print_r($emparray);
    		//echo json_encode($emparray);
    		$output = array(
    	   'c2array' => true,
    	   'size' => array(
    	       0 => count($emparray),
    	       1 => 1,
    	       2 => 1
    	   ),
    	   'data' => array()
    	    );
    
    	    $x = 0;
    	    foreach ($emparray as $value) {
    	   $output['data'][$x] = array();
    	   $output['data'][$x][0] = array();
    	   $output['data'][$x][0][0] = $value["nombre"];
    	   $x++;
    	    }
    
    	    echo json_encode($output);
    [/code:2vqhamr3]
    
    Now the array data is correct in the debug layout.
    [code:2vqhamr3]{"c2array":true,"size":[7,1,1],"data":[[["test"]],[["Oscar"]],[["Oscar"]],[["test"]],[["test"]],[["oscar"]],[["Oscar"]]]}[/code:2vqhamr3]
    But the combobox is showing infinite options. lol
    
    ---UPDATE----
    
    I did it! 
    I fix the combobox like this:
    [img="http://s13.postimg.org/is1qrumdz/Sin_t_tulo.png"]
    OK now, how can i add an id in the same JSON? i mean i want to get the id of the users from the database, i guess i need them in the JSON query so i have to modify the SQL query to show it on the JSON but i dont know in what format.
    
    Now my JSON looks like this:
    
    [code:2vqhamr3]{"c2array":true,"size":[7,1,1],"data":[["2","test"],["3","Oscar"],["4","Oscar"],["5","test"],["6","test"],["7","oscar"],["8","Oscar"]]}[/code:2vqhamr3]
    
    The number are the id´s of each name in the db, but the c2 array shows only the id of each element but no the name, i want to show the name in the combobox but use the id to work with the mysql db.
  • Thanks for the quick reply

    Can you help me with the json format?

    This is my php

    $emparray = array();
    		// Start looping rows in mysql database.
    		while($rows=mysqli_fetch_assoc($result)){
    			$emparray[] = $rows;
    		// close while loop 
    		}
    		echo json_encode($emparray);
    [/code:wvakingv]
    what do i have to add to get that format?
    
    Thanks in advance!
  • Hi,

    Thanks for the reply

    im sorry for the delay but here is the screenshot and the array:

    The JSON array is:

    [{"nombre":"test"},{"nombre":"Oscar"},{"nombre":"Oscar"},{"nombre":"test"},{"nombre":"test"},{"nombre":"oscar"},{"nombre":"Oscar"}][/code:z9g7g4el]and the code:
    [img="http://s12.postimg.org/xdfzouu7x/Sin_t_tulo.png"]
    can you help me plz?
    
    Thanks in advance.
  • Can you plz show me an example how?

    im trying but i only get a blank list.

  • I have an array from a json.

    System | On start of layout - Request URL (tag "mytag")

    AJAX On "mytag" completed - Array | Load from JSON string ajax.LastData

    Is there a way i can fill a drop down list with my json array?

    Can you help me plz?

  • Tthanks ramones,

    You help me so much!

    the right answer: "name=" & name & "&phone=" & phone & "&email=" & email

    You can close this.

  • Hi,

    I want to post data to a php using ajax. The php store the info to mysql database.

    i have this:

    Global text: ""

    Global number: 0

    Global email: ""

    The globla variables are the text of the respective text field.

    On button clicked - action - Ajax send "name=name&phone=phone&email=email" to localhost method "POST"

    But when i look to my db i see this: name 0 email (the 0 is because the field is int)

    How can i send variables through ajax?

    Thanks.

  • Hi,

    Is Inca Dance a creative commons music?

  • can you send me the file cause i dont have it.

    Thanks.

  • How can i put a black background opacity to 0 when a circle overlapping it and only the circle part even if the circle move around?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ok,

    thanks for that.

    So i can�t run external files with c2...

    thanks

ozkr's avatar

ozkr

Member since 21 Jun, 2013

None one is following ozkr yet!

Trophy Case

  • 11-Year Club
  • Email Verified

Progress

12/44
How to earn trophies