Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8421183
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T03:04:43+00:00 2026-06-10T03:04:43+00:00

I need to display specific value of key ‘pasdiz_alus’ from array $form->data into a

  • 0

I need to display specific value of key 'pasdiz_alus' from array $form->data into a table cell. And I need to display this table row only if value of key 'pasdiz_alus' is greater than '0'.

The code for this is below, but the problem is that output displays also the value of key 'pasdiz_alus' above my table row and there it is displayed as many times as number of keys of array.

How can I get rid of this display of value of ” 'pasdiz_alus' x times of number of keys in array (in my case 29 times – there are 29 keys in the array)”? In this case it is: 5454545454545454……

My code is:

<table style="width: 800px;">
<tbody>
<?php
if ($form->data['pasdiz_alus'] > 0){
    echo '<tr><td style="width: 100px;">Bilde šeit</td><td style="width: 500px;">  <strong>Pašdizainēts alus</strong></td>';

foreach($form->data as $key => $value) {
    if($key === 'pasdiz_alus')
    echo '<td style="width: 100px;">';
            echo $form->data['pasdiz_alus'];
        echo '</td>';
    }
      echo '<td style="width: 100px;">Cena šeit</td></tr>';
}
?>
</tbody>
</table>

And this is the output display, in this case the value of 'pasdiz_alus' is 54
The first row is the “wrong” one that I need to get rid off, and the second row is the “right” one.

5454545454545454545454545454545454545454545454545454545454
Bilde šeit      Pašdizainēts alus       54      Cena šeit

Thanks for helping!
Brgds, Raivis

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T03:04:45+00:00Added an answer on June 10, 2026 at 3:04 am

    The problem in your script is here:

    if($key === 'pasdiz_alus') // <-- missing opening "{"
        echo '<td style="width: 100px;">'; // <-- inside the "if"
        echo $form->data['pasdiz_alus']; // <-- OUTSIDE the "if"
        echo '</td>'; // <-- OUTSIDE the "if"
    } // <-- this matches the foreach "{"
    

    Why do you cycle all the array keys, instead of directly accessing it?

    <table style="width: 800px;">
        <tbody>
        <?php if ($form->data['pasdiz_alus'] > 0) { ?>
            <tr>
                <td style="width: 100px;">Bilde šeit</td>
                <td style="width: 500px;"><strong>Pašdizainēts alus</strong></td>
                <td style="width: 100px;"><?=$form->data['pasdiz_alus']?></td>
                <td style="width: 100px;">Cena šeit</td>
            </tr>
        <?php } ?>
        </tbody>
    </table>
    

    This should solve your problem, but I’d recommend also to move the if part before even opening the table:

    <?php if ($form->data['pasdiz_alus'] > 0) { ?>
    <table style="width: 800px;">
        <tbody>
            <tr>
                <td style="width: 100px;">Bilde šeit</td>
                <td style="width: 500px;"><strong>Pašdizainēts alus</strong></td>
                <td style="width: 100px;"><?=$form->data['pasdiz_alus']?></td>
                <td style="width: 100px;">Cena šeit</td>
            </tr>
        </tbody>
    </table>
    <?php } ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i need to display value of <input> into the <span> and when label become
I need to get rather complicate JSON data from (large) JSON file into a
I need to display checkbox in extjs property grid for a specific property. From
I need to display application settings screen for a specific system application in my
I need to display short description like label and near it data associated with
I need to display the parent from the first Element of input.xml Also I
Hi I need to display in DropDownList a list of Users belonging a specific
In my php web site, I need to display my urn in a specific
i am developing one application with map view i need display the weather depends
I need to display image and one button on fancybox popup but I can't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.