html - I would like to format my list data from a MySQL database into even rows and columns -


essentially title says. have looked @ other examples don't seem fit requirements. echoing out data database user in list format. appear rows , columns when displayed.

here current css code

.recent_items{     margin-left: 10%;     margin-right: 10%; }  .item li{     list-style: none;     display: inline-block;     padding: 10px; } .item{    width:85%; } 

and here php code data

<?                     $per_page = 30;                     $pages_query = mysql_query("select count(*) ads") or die(mysql_error());                     $pages = ceil(mysql_result($pages_query, 0)/ $per_page);                     $curr_page = (isset($_get['page'])) ? (int)$_get['page'] : 1;                     $start = ($curr_page - 1) * $per_page;                      //get ad information                     $ad_info = mysql_query("select * ads order datecreated desc limit $start, $per_page") or die(mysql_error());                     $rows = mysql_num_rows($ad_info);                      echo '<ul class="item">';                     while($row = mysql_fetch_array($ad_info)){                         $ad_id = $row['adid'];                         $title = $row['title'];                         $price = $row['price'];                         $location = $row['location'];                          $ad_type = mysql_query("select * types adid=$ad_id") or die(mysql_error());                         while($row = mysql_fetch_array($ad_type)){                             $cat = $row['category'];                             $sub = $row['subcat'];                              echo                             "                                 <li>$title</br>                                 <label>price:</label> $price</br>                                 <label>location:</label> $location</br>                                 <a href=\"search.php?searchvalue=".$cat."\">$cat</a>/<a href=\"search.php?searchvalue=".$sub."\">$sub</a></li>                             ";                         }                     }                     echo '</ul>';                      if($pages >= 1 && $curr_page <= $pages){                         for($x = 1; $x <= $pages; $x++){                            echo ($x == $curr_page) ? "<b><a href=\"?page=$x\">$x</a></b> " : "<a href=\"?page=$x\">$x</a> ";                         }                     }                 ?> 

the problem css , php code come out looking this: https://twitter.com/hassannsaid/status/320364537477996544/photo/1

as can see columns not alined. tried altering width happened item moved 1 row.

thanks in advance

you should define width li elements.

.item li{     list-style: none;     display: inline-block;     padding: 10px;     width: 25%; /* give 4 columns */ } 

the width on .item corresponds outer container width...your li elements determine column width. essentially, saying want whole list occupy 85% of window width. since didn't define width li did should act inline elements, shrink down fit inner content (giving varying widths). specifying width of li, saying want them same. if content on line greater width, end wrapping.


Comments

Popular posts from this blog

ios - iPhone/iPad different view orientations in different views , and apple approval process -

java Extracting Zip file -

C# WinForm - loading screen -