williamh69 0 Posted November 11, 2019 Share Posted November 11, 2019 hi trying to make a grid of two columns , data from db using mysqli and php, but it does not work...can you guys help me thanks in advance <?php $limit=2; $count=0; echo"<table border='0' align='center' cellpadding='2' cellspacing='2' width='70%'>"; $query = "SELECT * FROM posts"; $select_all_categories_query = mysqli_query($connection, $query); while ($row = mysqli_fetch_assoc($select_all_categories_query)){ $post_image = $row['post_image']; $post_title = $row['post_title']; $post_content = $row['post_content']; $post_user = $row['post_user']; $post_date = $row['post_date']; if ($count < $limit) { if($count ==0) { echo"<tr>"; } echo"<div class='post-img'>"; echo"<div class='img'>"; echo"<img src='assets/img/blog/$post_image' alt='Blog'>"; echo"</div>"; echo"<div class='tag'>"; echo"<a href='#'><span class='icon'><i class='fas fa-tags'></i></span> Business</a>"; echo"</div>"; echo"</div>"; echo"<div class='cont'>"; echo"<h6><a href='blog-single.html'>$post_title</a></h6>"; echo"<p>$post_content</p>"; echo"<div class='info'>"; echo"<a href='#'><span class='author'><img src='assets/img/blog/4.png' alt='Post'></span>$post_user</a>"; echo"<a href='#' class='right'><span class='icon'><i class='fas fa-clock'></i></span> $post_date</a>"; echo"</div>"; echo"</div>"; }else { $count=0; echo"<div class='post-img'>"; echo"<div class='img'>"; echo"<img src='assets/img/blog/$post_image' alt='Blog'>"; echo"</div>"; echo"<div class='tag'>"; echo"<a href='#'><span class='icon'><i class='fas fa-tags'></i></span> Business</a>"; echo"</div>"; echo"</div>"; echo"<div class='cont'>"; echo"<h6><a href='blog-single.html'>$post_title</a></h6>"; echo"<p>$post_content</p>"; echo"<div class='info'>"; echo"<a href='#'><span class='author'><img src='assets/img/blog/4.png' alt='Post'></span>$post_user</a>"; echo"<a href='#' class='right'><span class='icon'><i class='fas fa-clock'></i></span> $post_date</a>"; echo"</div>"; echo"</div>"; } $count++; } echo"</tr></table>"; ?> this is the result i want this kind of result thank you Quote Link to post Share on other sites
cyberRobot 126 Posted November 12, 2019 Share Posted November 12, 2019 Note that HTML table tags (e.g. <table>, <tr>, <td>) should be reserved for tabular data. Perhaps one of the solutions found here will help:https://css-tricks.com/fluid-width-equal-height-columns/ You could also consider using CSS grids:https://css-tricks.com/snippets/css/complete-guide-grid/ Just be aware that browser support isn't exactly ideal for CSS grids. More information can be found here:https://caniuse.com/#feat=css-grid Quote Link to post Share on other sites
NotSunfighter 6 Posted November 12, 2019 Share Posted November 12, 2019 @williamh69 Next time you make a table remember to use <td> not <div> and You need a <tr> in there if($count ==0) { echo"<tr>"; } should have been just echo "<tr> No if. and <table border='0' align='center' cellpadding='2' cellspacing='2' width='70%'> Is totally out of date and wrong. Quote Link to post Share on other sites
williamh69 0 Posted November 15, 2019 Author Share Posted November 15, 2019 ok thanks Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.