Jump to content

3 columns per row from database


Pesmerga_007

Recommended Posts

Hey guys. I found a code that basically lets me display information like this:

 

tempfxe.jpg

 

However, I can only get the array to find one attribute from a table (thumblink). I want to get both the thumblink AND id number so I can link the thumbnails to their respective pages.

 

I have no idea how to get the array to get two values from each row.

 

Any help would be awesome.

 

 

while($invitationsloop = mysql_fetch_array($returned_data)) {

$arr[] = $invitationsloop[thumblink];


}



$max_num_cols = 3; //the maximum amount of columns that can be output
$min_items_per_col = 1; //The minimum amount of items per column
$col_limit_calculation = $max_num_cols * $min_items_per_col; //used to determine which value to chunk by
$num_rows = count($arr); //total number of items in the array

//determins how many values to chunk our array by while still keeping with our $max_num_cols
$chunk_count = ($num_rows >= $col_limit_calculation) ? ceil(($num_rows / $max_num_cols)) : $min_items_per_col;

//The chunked array that we get to loop through now
$alphabet_chunk_array = array_chunk($arr, $chunk_count);

echo "<table border='1' width='100%'><tr>";
foreach ($alphabet_chunk_array as $alphabet_array) {
    echo "<td width='33%' valign='top'>";
    foreach ($alphabet_array as $alphabet) {
        


	echo "<a href='showinvite.php?id='3''><img src='" .$alphabet . "'></a><br />";


}
    echo "</td>";
}
echo "</tr></table>";

Link to comment
https://forums.phpfreaks.com/topic/154986-3-columns-per-row-from-database/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.