Jump to content

Displaying Array Output in a table


Mugan

Recommended Posts

I have a function which finds a list of companies associated with a country from a custom taxonomy. It finds their logo and creates an output which is all logos associated with a country, and the logo has a href to link to a company page. The code for this is:

function countryCompanies(){

global $post;

    $echo = f_print(array(
        'data' => 'p2p',
        'type' => 'mainlogo',
        'args' => array(
            'connection_type' => 'client'.$_set['lang_postfix'].'_to_location'.$_set['lang_postfix'].'',
            'post_type' => 'client',
            'connection_id' => $post->ID,
            'alternative' => "",
        ),
));

 

The f_print function finds the logos, and their sizes. So the 'mainlogo' type is a pull down of the thumbnail at 200px size.

 

What I need to do is write CSS and PHP which will display these results in a grid, 4 colums across, and as many down as results from the array. At the moment all I can get is all the results in one column.

What tutorials would I need to write appropriate CSS to create this, and then is it as simple as adding the div prior to the echo of the $echo variable?

Thanks

Link to comment
Share on other sites

Hi,

 

Thanks for the feedback. So I am working with some original code built for the site, so the f_print naming function is some legacy naming, so its taken me a while to work out what the function was doing, as original developer didnt leave any comment either. 

In terms of the output, I believe it is pulling some div based CSS to create the output in a grid. Here is the code pulled from a different area of the original site where this works:

 

<div class="inner">

                                <div class="row">

                                                <div class="w6 featured">

                                                                <h2>Clients</h2>

                                                                <div class="content_box clearfix">

<div class="logo_th"><a href="***link***"><img width="70" height="30" src="***source***" class="attachment-logo size-logo wp-post-image" alt="" srcset="***source*** 70w, ***source*** 300w, ***source*** 624w, ***source*** 800w" sizes="(max-width: 70px) 100vw, 70px"></a></div>

<div class="logo_th"><a href="***link***"><img width="70" height="30" src="***source***" class="attachment-logo size-logo wp-post-image" alt="" srcset="***source*** 70w, ***source*** 300w, ***source*** 624w, ***source*** 800w" sizes="(max-width: 70px) 100vw, 70px"></a></div>

                                                                </div>

                                                </div>

                                </div>

 

Unfortunately, although i've added the same div's to my echo, it had no result, so it isnt picking them up in the code when I've written it. Do I need to construct a whole new css section to instruct the echo output?

 

thanks

Link to comment
Share on other sites

Try using plain html code instead of echo'ing everything out.

And - if you didn't write the div to do all this, why bother trying to understand someone else's mindset?  Write it as an html table.  Much simpler.  Start with a plain non-styled table and then when it is working you can customize it with some css

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.