• Resolved Upadesh

    (@upadeshs)


    I am using the following code below but was able to display only the last data group. What is wrong with the code. How to display repeated data.

    <?php $repeatable_field_values = simple_fields_values("rec_name,rec_desc,rec_homeurl,rec_logo");
    	foreach ($repeatable_field_values as $values)
    		$file_id = $values["rec_logo"];
            $image_info = wp_get_attachment_image_src($file_id, "thumbnail");
            $image = $image_info[0];
    {
    	echo "<table border='1' cellspacing='1' cellpadding='1' style='width: 100%'>
          <tbody>
            <tr>
              <td rowspan='3' colspan='1' style='text-align:center;'><img src='$image' alt='".$values["rec_name"]." logo'/></td>
              <td rowspan='1' colspan='3' style='text-align:center;'><a href='".$values["rec_homeurl"]."' target='_blank'><strong>".$values["rec_name"]."</strong></a></td>
            </tr>
            <tr>
              <td rowspan='1' colspan='3'>".$values["rec_desc"]."</td>
            </tr>
            <tr>
              <td><a href='".$values["rec_homeurl"]."' target='_blank'>Home</a></td>
              <td></td>
              <td></td>
            </tr>
          </tbody>
        </table>";
    }
    ?>

    Please help!

    https://www.ads-software.com/extend/plugins/simple-fields/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Contributor eskapism

    (@eskapism)

    It looks ok I think. If you just write

    print_r($repeatable_field_values);

    do you get/see all values in that array?

    Thread Starter Upadesh

    (@upadeshs)

    Yes sir I can see all the values in array. So what can I do next?

    Plugin Contributor eskapism

    (@eskapism)

    Ah, I think you made a small error in your code. The way you loop/use the foreach seems a bit odd. Try this version instead:

    <?php
    $repeatable_field_values = simple_fields_values("rec_name,rec_desc,rec_homeurl,rec_logo");
    foreach ($repeatable_field_values as $values) {
    	$file_id = $values["rec_logo"];
    	$image_info = wp_get_attachment_image_src($file_id, "thumbnail");
    	$image = $image_info[0];
    	echo "<table border='1' cellspacing='1' cellpadding='1' style='width: 100%'>
          <tbody>
            <tr>
              <td rowspan='3' colspan='1' style='text-align:center;'><img src='$image' alt='".$values["rec_name"]." logo'/></td>
              <td rowspan='1' colspan='3' style='text-align:center;'><a href='".$values["rec_homeurl"]."' target='_blank'><strong>".$values["rec_name"]."</strong></a></td>
            </tr>
            <tr>
              <td rowspan='1' colspan='3'>".$values["rec_desc"]."</td>
            </tr>
            <tr>
              <td><a href='".$values["rec_homeurl"]."' target='_blank'>Home</a></td>
              <td></td>
              <td></td>
            </tr>
          </tbody>
        </table>";
    }
    ?>
    Thread Starter Upadesh

    (@upadeshs)

    Woohhhhaa! It’s working like a charm. Thanks!!! You are awesome! But I can’t figure it out what was mistake in my script? Anyways thanks for help.

    Thread Starter Upadesh

    (@upadeshs)

    Yeah! I

    Thread Starter Upadesh

    (@upadeshs)

    Yeah! I figured out what mistake was. Thanks a billion to solve my problem.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Displays only last data’ is closed to new replies.