Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author ka2

    (@ka2)

    Hi there,
    Thank you for your inquiry.

    That is, do you want to output the only values of the “properties” column into the horizontal row?

    So, it is feasible if you use a PHP script.
    For example is as follow:

    global $cdbt;
    
    $data = $cdbt->get_data( 'your_table_name', 'properties' );
    
    $html = '<table class="table table-bordered"><tr>';
    foreach ($data as $value) {
      $html .= sprintf('<td>%s</td>', $value->properties);
    }
    $html .= '</tr></table>';
    
    echo $html;

    Do you have become the answer you desire?

    Thread Starter shokunbis

    (@shokunbis)

    Thanks Ka2,
    I just relaised I didn’t explain myself very well.
    This does alot, however if you check this link https://www.mcorealestate.com/sales-2
    in the address column I want to output another table inside with the data in rows and not column.

    Thread Starter shokunbis

    (@shokunbis)

    I am trying to build a custom real estate db using your plugin because its very flexible, however I am stuck because I am kinda new with WordPress.

    this is what I intend to achieve

    https://www.mcorealestate.com/wp-content/uploads/2015/06/sample.jpg

    Best Regards

    Plugin Author ka2

    (@ka2)

    Thank you,
    Well, I could understand what you want.

    We can not be realized by shortcode, so we should be addressed by script of php.
    For example is as follows:

    global $cdbt;
    
    $images = $cdbt->get_data( 'my_images_table', 'ID,image_url' );
    $data = $cdbt->get_data( 'my_properties_table', '*' );
    
    $outer_table = '<table class="table table-bordered"><thead><tr><th>Column1</th><th>Column2</th></tr></thead><tbody>';
    foreach ($images as $value) {
      $outer_table .= sprintf('<tr><td><img src="%s" width="128"></td>', $value->image_url);
      foreach ($data as $datum) {
        if ($datum->ID === $value->ID) {
          $inner_table = '<table>';
          foreach ($datum as $k => $v) {
            $inner_table .= sprintf( '<tr><th>%s</th><td class="text-left">%s</td></tr>', $k, $v );
          }
          $inner_table .= '</table>';
          break;
        }
      }
      $outer_table .= isset($inner_table) ? sprintf('<td>%s</td></tr>', $inner_table) : '<td>no data</td></tr>';
      unset($inner_table);
    }
    $outer_table .= '</tbody></table>';
    
    echo $outer_table;

    Screenshot image of the result that has run the above code is here.

    https://ka2.org/assets/2015/06/example_image.png

    How about this?

    Thread Starter shokunbis

    (@shokunbis)

    Thanks so much Ka2, works like magic

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘table within a each cell of a particular column’ is closed to new replies.