how to display specific value from array fetched from database codeigniter - Hack The Tech - Latest News related to Computer and Technology

Hack The Tech - Latest News related to Computer and Technology

Get Daily Latest News related to Computer and Technology and hack the world.

Saturday, October 1, 2022

how to display specific value from array fetched from database codeigniter

I'm new to Codeignitor. My senior had previously used the following code to retrieve an array from a database. It retrieves all of the items in the database, but I only want the first one, Please Help:

 <?php $custom_fields = get_custom_fields('projects');
         if(count($custom_fields) > 0){ ?>
         <?php foreach($custom_fields as $field){ ?>
         <?php $value = get_custom_field_value($project->id,$field['id'],'projects');
         if($value == ''){continue;} ?>
         <tr>
            <td class="bold"><?php echo ucfirst($field['name']); ?></td>
            <td><?php echo $value; ?></td>
         </tr>
         <?php } ?>
         <?php } ?>  ```

**I attempted to retrieve the data using index key [1], but I failed miserably.**

``<?php $custom_fields = get_custom_fields('projects');
         if(count($custom_fields) > 0){ ?>
         <?php foreach($custom_fields as $field){ ?>
         <?php $value = get_custom_field_value($project->id,$field['id'],'projects');
         if($value == ''){continue;} ?>
         <tr>
            <td class="bold"><?php echo ucfirst($field[0 &&'name']); ?></td>
            <td><?php echo $value[0]; ?></td>
         </tr>
         <?php } ?>
         <?php } ?> ```

I tried using index key [0] but i got miserably failed. 


source https://stackoverflow.com/questions/73902176/how-to-display-specific-value-from-array-fetched-from-database-codeigniter

No comments:

Post a Comment