Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 07-13-2022, 09:39 AM   #1
Publisher Bucks
Confirmed User
 
Industry Role:
Join Date: Oct 2018
Location: New Orleans, Louisiana. / Newcastle, England.
Posts: 1,123
Grid layout not working

So I have the following code on a page that I *think* should be working to display the data in a grid of 4 columns with 1 row in each column:

Quote:
<?php
$rows = $result->num_rows; // Find total row
if($rows > 0) {
$cols = 4; // column count
$counter = 1; //start or end row
$nbsp = $cols - ($rows % $cols); // blank column

$container_class = 'container-fluid'; // Grid class
$row_class = 'row'; // Row class
$col_class = 'col-sm-4'; // Column class

echo '<div class="'.$container_class.'">'; // Grid open
while ($item = $result->fetch_array()) {
if(($counter % $cols) == 1) { // Check new row
echo '<div class="'.$row_class.'">'; // Start new row
}
$img = "".$item['Cover'];
echo '<div class="'.$col_class.'"><img src="'.$img.'" width="180px" height="180px" alt="'.$item['Title'].'"/><h5>'.$item['Title'].'</h5></div>'; // Column content
if(($counter % $cols) == 0) { // last column then 0
echo '</div>'; // Close row
}
$counter++; // Increase counter
}
$result->free();
if($nbsp > 0) { // unused column in last row
for ($i = 0; $i < $nbsp; $i++) {
echo '<div class="'.$col_class.'">&nbsp;</div>';
}
echo '</div>'; // Close row
}
echo '</div>'; // Close container
}
?>
But it only appears to work showing the data in one continuos column, any idea why or pointers as to where I messed up the code please?

I was pretty sure I had this from the outset but apparently not
__________________
NOTHING TO SEE HERE
Publisher Bucks is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 07-13-2022, 10:30 AM   #2
Publisher Bucks
Confirmed User
 
Industry Role:
Join Date: Oct 2018
Location: New Orleans, Louisiana. / Newcastle, England.
Posts: 1,123
Nevermind, the code is fine, it was an error in calling the class in the css.
__________________
NOTHING TO SEE HERE
Publisher Bucks is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 07-13-2022, 02:18 PM   #3
blackmonsters
Making PHP work
 
blackmonsters's Avatar
 
Industry Role:
Join Date: Nov 2002
Location: 🌎🌅🌈🌇
Posts: 20,227
__________________
Make Money with Porn
blackmonsters is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 07-13-2022, 04:44 PM   #4
Publisher Bucks
Confirmed User
 
Industry Role:
Join Date: Oct 2018
Location: New Orleans, Louisiana. / Newcastle, England.
Posts: 1,123
This is just the base code, theres going to be pagination (based on how many items there are to display) included from the database based on keyword search too, I was told using a bootstrap based layout with the sql query stuff would be the better option?
__________________
NOTHING TO SEE HERE
Publisher Bucks is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks

Tags
data, grid, code, column, messed, pointers, continuos, idea, outset, apparently, crap, pretty, display, page, columns, appears, layout, row



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.