I'm trying make a dynamic table with a column count, but I can't get the column count out of my sql query
Tag : php , By : Yolanda N. Ceron
Date : March 29 2020, 07:55 AM
Hope this helps I'm trying to make a dynamic table that counts the columns in a certain table, returns this value, and then builds a table according to this count. My code below is without the any extra table rows, but I don't even get this first table row to appear. , I figured it out: $query = "DESCRIBE $tablename";
$result = $this->mysqli->query($query);
$colcnt = (count(mysqli_fetch_array($result)) / 2);
|
Count all rows from a column, and get 2 different count columns on the result even if there are not records to count
Date : March 29 2020, 07:55 AM
I hope this helps . Use Left Join to get all the rows from subcategory table and then do the Count. SELECT S.subcategoryID,
Sum(CASE WHEN state = 1 THEN 1 ELSE 0 END) AS active,
Sum(CASE WHEN state = 0 THEN 1 ELSE 0 END) AS inactive
FROM subcategory s
LEFT JOIN product p
ON s.SubcategoryID = p.Subcategory
GROUP BY s.subcategoryID
SELECT S.subcategoryID,
count(CASE WHEN state = 1 THEN 1 END) AS active,
count(CASE WHEN state = 0 THEN 1 END) AS inactive
FROM subcategory s
LEFT JOIN product p
ON s.SubcategoryID = p.Subcategory
GROUP BY s.subcategoryID
|
Dynamic column count grid for responsive web design
Tag : css , By : Robert M
Date : March 29 2020, 07:55 AM
This might help you Are you familiar with Bootstrap grid system? https://getbootstrap.com/examples/grid/Get a link for Bootstrap CDN from here ( https://www.bootstrapcdn.com/) and link to your html and try this: <div class="container">
<div class="col-md-3 col-sm-4 square">1</div>
<div class="col-md-3 col-sm-4 square">2</div>
<div class="col-md-3 col-sm-4 square">3</div>
<div class="col-md-3 col-sm-4 square">4</div>
<div class="col-md-3 col-sm-4 square">5</div>
<div class="col-md-3 col-sm-4 square">6</div>
<div class="col-md-3 col-sm-4 square">7</div>
<div class="col-md-3 col-sm-4 square">8</div>
</div>
.square {
border:solid;
border-color: WHATEVERCOLOR;
width: 200px;
height: 200px;
}
|
Create count column for each artist or get count in query (count followers)
Tag : mysql , By : user158220
Date : March 29 2020, 07:55 AM
I wish this help you It will be quicker to get the data with method A but the data might be stale as it might not reflect the true count. (You will have to keep on updating the count with method A on a periodic basis) With method B, it will be slower but you will a real time count. If it's not important to show the count on a real time basis then I would suggest that you go with method A and then update the follower count on a periodic basis
|
Creating a fixed row height/auto column count grid layout with css grid
Tag : css , By : protagonist
Date : March 29 2020, 07:55 AM
this one helps. CSS grid isn't a good fit for the layout you want. Luckily you can use flexbox to achieve something similar: .grid {
display: flex;
flex-wrap: wrap;
}
img {
flex: 1;
height: 200px; /* or whatever fixed height you need */
max-width: 100%;
object-fit: cover;
}
|