[Solved] I want make a list and and show in double list [closed]


You need to count the records, and then calculate how many rows are required per column:

$result = mysql_query("SELECT * FROM `my_table` WHERE `foo` = 'bar'");
$num_records = mysql_num_rows($result);
$num_columns = 2;
$rows_per_col = ceil($num_records / $num_columns);
$records = array();

while($row = mysql_fetch_array($result))
{
    $records[] = $row;
}

// Now get the columns in two arrays:
$col1 = array_slice($records, 0, ($rows_per_col - 1));
$col2 = array_slice($records, $rows_per_col);

// Now loop over the data:
echo '<div class="col">';
foreach($col1 as $row) 
{
    echo "\n\t", '<span class="row">', $row, '</span>';
}
echo '</div>';
echo '<div class="col">';
foreach($col2 as $row) 
{
    echo "\n\t", '<span class="row">', $row, '</span>';
}
echo '</div>';

Then you need to add some CSS to float the columns left, and set their width:

div.col {
    float: left;
    padding: 2%;
    width: 46%;
}
    div.col span.row {
        display: block;
        line-height: 20px;
    }

1

solved I want make a list and and show in double list [closed]