Skip to:
Content
Pages
Categories
Search
Top
Bottom

Data from database


  • sameast
    Participant

    @sameast

    Hi Guys

    I need some help i am using this code in my profile-loop.php file and it does the job it echos out all the data from my check boxes (Sector) section in the database.

    $platforms = xprofile_get_field_data('Sector');
    $data = xprofile_format_profile_field('checkbox', $platforms);
    echo $data;

    this is the data that i get outputted ,

    “Manufacturing, Bio science, Public sector, Transport/logistics, Environmental”

    (Which is great because these are my check boxes within the Sector section).

    The problem im having is. Its all just one big block off text i need to wrap a list element around each individual one for styling.

    like this.

    • Manufacturing
    • Bio science
    • Public sector
    • Transport/logistics
    • Environmental

    Could anyone tell me how to do this?

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • Then you need to run a ‘while’ or ‘foreach’ loop on that data don’t you? can you simply not copy a posts loop then you wrap each in a li element, first having set ul parent displayed only if data exists.


    sameast
    Participant

    @sameast

    Hi ive got it working probably not the best way to do it but it works.

    I did a var_dump on the $data variable and it outputs the following.

    string(77) “Manufacturing, Bio science, Public sector, Transport/logistics, Environmental”

    so i used the following.

    $platforms = xprofile_get_field_data('Sector');
    
    $data = xprofile_format_profile_field('checkbox', $platforms);
    
    $test = explode(',', $data);
    
    foreach( $test as $key => $value )
    {
    echo '<li>' . $value . '</li>';
    }
    

    Might help someone or not thanks hnla.

    I’m no master of PHP but what you described above is exactly what I would have written, there probably is a better approach if one had a deeper knowledge of BP/WP though.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Data from database’ is closed to new replies.
Skip to toolbar