Changeset 31599 for trunk/www


Ignore:
Timestamp:
Nov 29, 2007, 4:52:52 AM (12 years ago)
Author:
jmpp@…
Message:
  • Fix the number of columns on 4, back to what I was doing a couple of hours ago (sfiera tells me it seems like I have too big a monitor and don't realize how bad what I did looks at smaller sizes :-P);
  • Calculate the number of entries for each column based on the total number of categories, divided by the number of columns;
  • Relocate some declarations to more appropriate places;
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/www/ports.php

    r31597 r31599  
    99    print_header('The MacPorts Project -- Available Ports', 'utf-8');
    1010    $portsdb_connect = mysql_pconnect($portsdb_host, $portsdb_user, $portsdb_passwd) or die("Can't connect to the MacPorts database!");
     11    $num_categories = categories_count();
    1112    $by = isset($_GET['by']) ? $_GET['by'] : '';
    1213    $substr = isset($_GET['substr']) ? $_GET['substr'] : '';
     
    2627    }
    2728?>
    28     <p>The MacPorts Project currently distributes <b><?php print ports_count(); ?></b> ports, distributed across <?php print categories_count(); ?>
    29     different categories and available below for viewing. This form allows you to search the MacPorts software index, last
    30     updated on <b><?php echo $date; ?> at <?php echo $time; ?></b>.</p>
     29    <p>The MacPorts Project currently distributes <b><?php print ports_count(); ?></b> ports, distributed across <?php print
     30    $num_categories; ?> different categories and available below for viewing. This form allows you to search the MacPorts software
     31    index, last updated on <b><?php echo $date; ?> at <?php echo $time; ?></b>.</p>
    3132
    3233    <br />
     
    6465
    6566<?php
    66                     while ($row = mysql_fetch_assoc($result)) {
     67                    $max_entries_per_column = floor($num_categories/4);
     68                    $columns = 0;
     69                    while ($columns < 4) {
    6770?>
    6871                        <li>
     
    7073<?php
    7174                                $entries_per_colum = 0;
    72                                 while (1) {
     75                                while ($row = mysql_fetch_assoc($result)) {
    7376?>
    7477                                    <li><a href="<?php echo $_SERVER['PHP_SELF']; ?>?by=cat&amp;substr=<?php echo urlencode($row['category']); ?>">
    7578                                    <?php echo htmlspecialchars($row['category']); ?></a></li>
    7679<?php
    77                                     if ($entries_per_colum == 14) break;
     80                                    if ($entries_per_colum == $max_entries_per_column) break;
    7881                                    $entries_per_colum++;
    79                                     $row = mysql_fetch_assoc($result);
    8082                                }
    8183?>
     
    8385                        </li>
    8486<?php
     87                        $columns++;
    8588                    }
    8689?>
Note: See TracChangeset for help on using the changeset viewer.