This topic is locked
[SOLVED]

 Show details from master table using DAL - JSON image URL

5/31/2014 10:57:23 AM
PHPRunner General questions
S
sporrencense author

Hi,
I have two tables:

  • paths_data (master)
  • trail_data (child)


In the paths_data table I have fields: path_name, path_description and bespokemap.

On the add page for the trail_data I wish to pull in the bespokemap image from the master table. I am using DAL to pull in the path_name and path_description successfully:

global $dal, $strTableName;

if ($_SESSION[$strTableName."_masterkey1"])

{

$tblOrders = $dal->Table("paths_data");

$rs = $tblOrders->Query("UID=".$_SESSION[$strTableName.

"_masterkey1"],"");

if ($data = db_fetch_array($rs))

{

echo "Path Name: ".$data["path_name"]."
";

echo "Path Description: ".$data["path_description"]."
";

echo "Bespoke Map: ".$data["bespokemap"]."
";

}

}


The bespokemap field contains JSON info of an uploaded image:

[{"name":"..\/media\/bespokemaps\/holystoneprimary\/1898map_zodflgkw.jpg","usrName":"1898map.jpg","size":99098,"type":"image\/jpeg","thumbnail":"..\/media\/bespokemaps\/holystoneprimary\/th1898map_dhfbrz5k.jpg","thumbnail_type":"image\/jpeg","thumbnail_size":13103,"searchStr":"1898map.jpg,!:sStrEnd"}]


I've tried a number of things that I have found in the instructions and on the forum to decode the JSON and pull out the file path so that I can display as an image but, not being very familiar with this side of things, I'm hitting a brick wall. I'm really hoping that someone can help me with this bit of code. It's really bugging me now.
Many thanks in advance.

Sergey Kornilov admin 6/1/2014

See example #1 at http://xlinesoft.com/phprunner/docs/rename_uploaded_file.htm

It shows how you can decode JSON format stored in one of database fields and access fields like file name or file path.

S
sporrencense author 6/4/2014

Thanks. I use phprunner as I am not a programmer but I will have a shot. I'd like to edit the event on the server first, till I get it right, so I don't have to keep uploading changes. For the life of me I can't find in which folder / file the events are written in the output folder - could you tell me please?
Thanks
Ben

S
sporrencense author 6/4/2014



See example #1 at http://xlinesoft.com/phprunner/docs/rename_uploaded_file.htm

It shows how you can decode JSON format stored in one of database fields and access fields like file name or file path.



Thanks. I use phprunner as I am not a programmer but I will have a shot. I'd like to edit the event on the server first, till I get it right, so I don't have to keep uploading changes. For the life of me I can't find in which folder / file the events are written in the output folder - could you tell me please?
Regards
Ben

Sergey Kornilov admin 6/4/2014

Ben,
events are stored in "include" folder in files like tablename_events.php.
I do not recommend though modifying output files. Much more easier and convenient to make changes in PHPRunner itself and use the built-in web server for testing purposes.

S
sporrencense author 6/4/2014

Thanks got it sorted.
For anyone else here is what i used

global $dal, $strTableName;

echo "Order Info
";

if ($_SESSION[$strTableName."_masterkey1"])

{

$tblOrders = $dal->Table("paths_data");

$rs = $tblOrders->Query("UID=".$_SESSION[$strTableName.

"_masterkey1"],"");

if ($data = db_fetch_array($rs))

{

$fileArray = my_json_decode($data["bspoke_map"]);

for($i = 0; $i < count($fileArray); $i++)

{

echo "Bespoke Map: ".$fileArray[$i]["name"]."
";

}

}

}