vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Columns not rows? (https://vborg.vbsupport.ru/showthread.php?t=72688)

Koutaru 12-09-2004 09:31 PM

Columns not rows?
 
I know I probably should know how to do this but I just can't get it right ^^;

Anyway, how do you make things display in columns instead of rows? Like after you grab data from the database, your bit template has to be different. Instead of just <tr><td> which will create just rows, how do you make it so there's 4 columns (of images in this case) instead?

Sorry for the confusing explanation.
Thanks! :ninja:

Jolten 12-09-2004 11:16 PM

Add a conditional for the <tr> tags. Like so:

Code:

<table width="600" align="center" cellpadding="4" cellspacing="8" class=alt2">
<?
$a=0;
while($row=mysql_fetch_object($XX))
{
                                               
        -- Variables placed here to call image title, file name in loop --
                                       
        if ($a == '0') {echo "<tr>";}
        if ($a == '4') {echo "</tr><tr>";}
        if ($a == '8') {echo "</tr><tr>";}
        if ($a == '12') {echo "</tr><tr>";}
        if ($a == '16') {echo "</tr><tr>";}
        if ($a == '20') {echo "</tr><tr>";}
                                               
        ?>
                                               
                               
        <td class="alt4" align="center" width="25%" valign="middle">
                                                       
        -- Image code here --
                                                       
        </td>
                               
      <?
        $a = $a + 1;
            }
        ?>

</table>

Note a is set to ? before the loop. Then the loop increases a with each pass. The conditionals add the closing and opening <tr> tags based upon cycles in the loop. This setup is designed to create 4 table cells before closing a row and opening a new row. The query is designed to only show a maximum of 20 images per page. That's why the conditionals stop at 20. I'm not certain this is the optimum way to do this. But it's been working great for me.

Koutaru 12-11-2004 12:24 AM

Thanks Jolten! I think I've tried doing that but it hasn't worked yet for me. >.> Maybe I did something wrong, but I'll follow your structure.

:)


All times are GMT. The time now is 12:16 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.00929 seconds
  • Memory Usage 1,715KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (3)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete