Ajax Request URL..
I store information in array because I do not want to display full path to video..
let's say you have on server something like this..
you can use list.php to get all sub-folders and files in video folder
<?php function listFolderFiles($dir){ $ffs = scandir($dir); foreach($ffs as $ff){ if($ff != '.' && $ff != '..'){ echo $ff. PHP_EOL; if(is_dir($dir.'/'.$ff)) listFolderFiles($dir.'/'.$ff);}}} listFolderFiles('video'); exit; ?>[/code:ewugl4oe] so..your ajax data will look like this: [img="http://lookpic.com/O/i2/1364/e8EIVxSr.png"] now you can loop through data and populate array and list object.. [url=https://app.box.com/s/nozesa4msrfq346aoohpq8ovmaicxvic]phpDir2List.capx[/url] if you upload a new videos or delete..even sub-folders in [b]videos/video[/b] folder.. you do not have to make any changes in php script or C2 code...
something like this?
demo2video.capx
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.
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]
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]
{"status":true,"message":"","data":{"prize":{"name":"BONUS","description":"BONUS 25","image":"cash","promo_code":"","position":15}}}[/code:fdqspyw3] i try with JSON.Value(0,"data","prize","position"), but its not working.
works for me...
Array(3,2,1)
{"c2array":true,"size":[3,2,1],"data":[[["one"],[4]],[["two"],["five"]],[[3],[6]]]}[/code:jx17tizg] [code:jx17tizg]{"c2array":true,"size":[3,2,1],"data": [ [["one"],[4]], [["two"],["five"]], [[3],[6]] ] }[/code:jx17tizg] Array(3,3,1) [code:jx17tizg]{"c2array":true,"size":[3,3,1],"data":[[["one"],[4],["seven"]],[["two"],["five"],["eight"]],[[3],[6],["nine"]]]}[/code:jx17tizg] [code:jx17tizg]{"c2array":true,"size":[3,3,1],"data": [ [["one"],[4],["seven"]], [["two"],["five"],["eight"]], [[3],[6],["nine"]] ] }[/code:jx17tizg] you can use Browser object [img="http://lookpic.com/O/i2/1996/vONpZEP6.png"] check also [url=https://www.scirra.com/forum/array-contents-editor-2d-3d-beta_t120926]Array contents editor[/url]
Develop games in your browser. Powerful, performant & highly capable.
maybe you can use Video plugin...
Mixing the File Chooser and Video plugin
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.
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...
<?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]
{"arraytext02":true,"size":[3,1,1],"data":[[["one"]],[["two"]],[[3]]]} {"c2array":true,"size":[3,1,1],"data":[[["one"]],[["two"]],[[3]]]}]
{"arraytext02":true,"size":[3,1,1],"data":[[["one"]],[["two"]],[[3]]]}
{"c2array":true,"size":[3,1,1],"data":[[["one"]],[["two"]],[[3]]]}]
not "yourFileName":true,"size":..... OR "yourArrayName":true,"size":.....
it's always c2array !!!
.. I can get the data into my program, but not into the array object. My array remains empty. ..
array.json
{"c2array":true,"size":[3,1,1],"data":[[["one"]],[["two"]],[[3]]]}[/code:1d0yfgst]
it may be better to use TextBox..
see the difference..
myLocalVar_test.capx
Quotation marks error..
json should look like
"{""c2"":true,""w"":{""x"":180,""y"":450,""w"":128,""h"":128,""l"":719120155086956,""zi"":0,""hX"":0}...[/code:1abp87kn] not [code:1abp87kn]"{'c2':true,'w':{'x':180,'y':450,'w':128,'h':128,'l':719120155086956,'zi':0,'hX':0}..[/code:1abp87kn]