JSON nested repeat region - how to do it?
I have a database table with one field that contains JSON . Each row of the database contains simple text fields called fields called TITLE, SUBTITLE, and DESCRIPTION, and the JSON data field called IMAGE
When the IMAGE JSON contains one image the following code works, but I have no clue how to add the code that would nest repeat all the images included in the JSON field as images.
The code I am using for single images per row is:
<?php
while(!$DETAILS->atEnd()) {
?>
<div class="row">
<div class="col-md-8">
<h2><?php echo($DETAILS->getColumnVal("TITLE")); ?></h2>
<p><strong><?php echo($DETAILS->getColumnVal("SUBTITLE")); ?></strong></p>
<?php echo($DETAILS->getColumnVal("DESCRIPTION")); ?>
</div>
<div class="col-md-4">
<strong>
<?php
$json = $DETAILS->getColumnVal("IMAGE");
//
$myArray = json_decode($json, true);
?>
<?php if ($DETAILS->getColumnVal("IMAGE") != "") { ?>
<img src="input/<?php echo $myImage = $myArray[0]["name"]; ?>" class="img-responsive center-block" alt="<?php echo $DETAILS->getColumnVal("TITLE"); ?>">
<?php } ?>
</div>
</div>
<?php
$DETAILS->moveNext();
}
$DETAILS->moveFirst(); //return RS to first record
?>
An example of the 'multi-image' JSON is : [{"name":"images\/03_y8osnwim.jpg","usrName":"03.jpg","size":98665,"type":"image\/jpeg","thumbnail":"images\/th03_jdfcm55b.jpg","thumbnail_type":"image\/jpeg","thumbnail_size":11684,"searchStr":"03.jpg,!11.jpg,!01.jpg,!12.jpg,!02.jpg,!13.jpg,!05.jpg,!14.jpg,!06.jpg,!:sStrEnd"},{"name":"images\/11_ipi01ygc.jpg","usrName":"11.jpg","size":96945,"type":"image\/jpeg","thumbnail":"images\/th11_g5cqaao1.jpg","thumbnail_type":"image\/jpeg","thumbnail_size":12155},{"name":"images\/01_xv69cder.jpg","usrName":"01.jpg","size":98327,"type":"image\/jpeg","thumbnail":"images\/th01_bep2e90t.jpg","thumbnail_type":"image\/jpeg","thumbnail_size":11359},{"name":"images\/12_mhancpnr.jpg","usrName":"12.jpg","size":104597,"type":"image\/jpeg","thumbnail":"images\/th12_4et19bu1.jpg","thumbnail_type":"image\/jpeg","thumbnail_size":10972},{"name":"images\/02_j1bblk53.jpg","usrName":"02.jpg","size":123075,"type":"image\/jpeg","thumbnail":"images\/th02_midqduuw.jpg","thumbnail_type":"image\/jpeg","thumbnail_size":13143},{"name":"images\/13_8iawh5dk.jpg","usrName":"13.jpg","size":108840,"type":"image\/jpeg","thumbnail":"images\/th13_ghuqpvtj.jpg","thumbnail_type":"image\/jpeg","thumbnail_size":11991},{"name":"images\/05_ujgcogbd.jpg","usrName":"05.jpg","size":116858,"type":"image\/jpeg","thumbnail":"images\/th05_o319l82a.jpg","thumbnail_type":"image\/jpeg","thumbnail_size":12247},{"name":"images\/14_lftyibpj.jpg","usrName":"14.jpg","size":127039,"type":"image\/jpeg","thumbnail":"images\/th14_5bzrctsz.jpg","thumbnail_type":"image\/jpeg","thumbnail_size":11481},{"name":"images\/06_urku1k0z.jpg","usrName":"06.jpg","size":174727,"type":"image\/jpeg","thumbnail":"images\/th06_73yma7ny.jpg","thumbnail_type":"image\/jpeg","thumbnail_size":15751}]
Any advice you can give would be much appreciated. MySQLi and JSON newbie!