HTML Customize table - php

I have been looking into table for a while, and I am thinking about creating something. The data will be stored in a database (profile image, name, description, date and thumbs up).
I am trying to create something like this: https://i.ibb.co/k2LM4ch/Untitled.png So each row from the database table has it's own card view(or list view, not sure what its named).
Can someone help to me the right path here, as I have no idea how I get do this, is even table the correct way?

This is a simple example with information you have provide:
$query=$mysqli->prepare('select * from table');
$query->execute();
$result=$query->get_result();
echo '<table>';
while($res=$result->fetch_array()){
$name=$res['name'];
$thumb=$res['thumbsup'];
echo "<tr><td><img src='$thumb'>$name <br> Hello <br> <button>test</button></td></tr>"
}
echo '</table>'
of course you will have to change the code according to your needs.
So for example how #Ludovit Mydla said use flex/grid for the two column

Right so your first question: should i use a table to make a card? No! absolutely not!
What you want to do first though is create a simple html page layout with your card design I tend to use Codepen for finding out card designs since the community is nice and you can use there designs if you follow the terms and agreement and credit people for there amazing work! Write this up in a php file
After youve created your page layout you'll need to create a registration form: the registration form will allow the person to fill out the information fields of profile image, name, description etc w3schools has a basic tutorial on that
You'll Then need to create a database which will then store the information from your w3schools form, and you'll be able to pull that information back into the fields your cards need in your simple html page layout design with MySQL code
If your coding skills are not the best! that is all good you might prefer to watch this
tutorial to get you started before trying to do the above 3 tasks! This youtube series should help you learn before trying something a little more complex

This answer takes care only of HTML + CSS part of the question and it's very simplistic. More styling will be needed probably. See other answers for SQL/PHP solutions. You can design the "card" in many ways (positioning, float, flex or grid layout) The example given is done with flex (just personal preference at the moment):
.card {
display: flex;
flex-flow: row nowrap;
justify-content: space-between;
align-items: flex-start;
border: 1px solid black;
}
.card_img {
flex: 0 1 100px;
padding: 5px;
}
.card_content {
flex: 1 0 70%;
}
.card_content > h3 {
margin: 0;
font-size: 1.5rem;
font-weight: bold;
}
.card_content > footer {
display: flex;
flex-flow: row nowrap;
justify-content: space-between;
}
<div class="card">
<div class="card_img"><img src="https://picsum.photos/100/100"></div>
<div class="card_content">
<h3>Joe Schmoe</h3>
<p>Lorem ipsum dolor sit amet ... </p>
<footer>
<button>Button</button>
<span>some text here</span>
</footer>
</div>
</div>

Related

How to localization things in the same line

im working on homepage of my web site like google. in the center one textbox for the search task, and search buton near it , but i have many problem with localization. firstly, i have words top of my web site and i want to locate in different places in same line . left and right. for example language options like DE / FR on the left, Login / Help on the right in the same line. to the right , i tried with this;
#right
{
position:relative;
top:10% ;
left:61%;
margin-right:10px;
}
<a href="login.php" id="right" >Login</a>
when i do this, its look like i want but when i make page smaller whole content messed up include search buton. And finally i tried to position button near the textbox like i said but i couldnt. i mean i have a problem position same lane things.. i looked here about my question but cant find exactly similar to mine, ty.
Here:http://jsfiddle.net/leojavier/gbuLykdj/3/
Just make you container display as table, and the content as a table cell. That will allow you to vertically center your elements
<div class='container'>
<section><input type="text" placeholder="search"><button>search</button></section>
</div>
CSS
html, body {
height:100%;
width:100%;
margin:0;
padding:0;
font-family:arial;
}
.container{
display:table;
height:100%;
width:100%;
}
section{
display:table-cell;
vertical-align:middle;
text-align:center;
}

Styling PDF's with multiple text columns

This is a PDF or HTML styling question: I want multiple text columns in my PDF.
I have a custom modification to PDFMaker's PDF Export tool for Vtiger. For the moment it looks as if I can only style inline in the elemnt style tag, generated from the php export module.
When using the text/code editor in the browser, my styles work fine. I am able to create text columns and everything looks great! (Thank to this genius! : http://jsfiddle.net/jalbertbowdenii/7Chkz/ ) ...I'm using this exact code, only inline.
.cols {
-moz-column-count:3;
-moz-column-gap: 3%;
-moz-column-width: 30%;
-webkit-column-count:3;
-webkit-column-gap: 3%;
-webkit-column-width: 30%;
column-count: 3;
column-gap: 3%;
column-width: 30%;
}
But when I export to PDF, it will not render columns..it stacks my child divs.
*Note: I did change all percentages to fixed widths (pdf seems to not like percentages...not sure on this, but seems like it)
So, is there something special about styling for PDF's to make it recognize columns? Or is there a proven work around in CSS to achieve multiple text columns?
Thanks in advance, Stackoverflow rocks!
After a few days and no replies, here is what I found out. There are different PDF "classes" ( not sure how to define class in this context)... but it's the library of code that interprets different forms of code for rendering a PDF, I've seen PHP, JQuery and HTML.
For the answer to my question, I needed to know what HTML styles the PDF 'class' I was using would work. It turns out that the library/class I was using was called mPDF
This class had nice documentation of styles and attributes it supports:
Supported CSS
HTML attributes
After reading through the docs, it appears that the 'column-count' style is not supported as well as floats are limited. It appears I can not achieve the 'masonry' style layout I'm looking for (at this time).
QUICK UDDATE ON LINK 2021: https://mpdf.github.io/
Add to add multi column function in the mpdf use the following code
<columns column-count="3" vAlign="J" column-gap="2"/>
<!-- add the dive with text etc here-->
<columns/>
For more details you check this website https://mpdf.github.io/reference/html-control-tags/columns.html
I found this in php
.row {
display:table;
width: 100%;
clear: both;
}
.col-lg-4 {
float: left;
width: 32.83%;
border:1px solid blue;
}
and php code here
<?php
$d = [1,2,3,4,5,6,7,8,9,10,11,12,13,14];
$cols = 3;
$dRowLen = ceil(count($d) / $cols);
?>
<?php for($i=0;$i<$dRowLen;$i++){ ?>
<div class="row">
<?php
$z = $i*$cols;
for($v=0;$v<$cols;$v++){
if(isset($d[$z+$v])){
?>
<div class="col-lg-4">
<?php echo $d[$z+$v];?>
</div>
<?php
}
}
?>
</div>
<?php } ?>

Having trouble with my website? Having problems aligning two divs

So i'm at the point where I feel like quitting, because of all the trouble this problem has given me. So if anyone could help me out that'd be great :D!
So on my website what I want to do is have a div box to the left of the website, where there will be a "Learn more" link that will take you to another page explaining what my website is about, I would also like there to be a video right below it (It will be of me explaining my website)
On the other div box I want there to be a "Sign Up form" a basic sign up form for users to sign up for my website
Now my problem isn't getting the boxes or sign up sheet aligned side by side.
Right now my problem is the alignment of the top of the boxes. When I put "float:left;" it aligned them side by side(exactly Like I wanted)
However one of the top borders of the box is higher up then the other
For example this is my website so far http://www.shoportrade.org/
As you can see the boxes don't align perfectly from the top of the border, one is lower then the other
I want it to look sorta like this http://www1.picturepush.com/photo/a/12506959/640/12506959.png
Could anyone help me? I've hit a wall and I really wanna figure this problem out.
I don't know why you have all the break tags, but this is what your syntax needs to be like:
<div id="header">
</div>
<div id="container">
<div class="ex">
</div>
<div class="myform">
</div>
<div class="clear"></div>
</div>
Your header would stay the same way. Your container needs to wrap both boxes. Usually this is center aligned on the page with this CSS:
.container { width:980px; margin: 0 auto; }
Your .ex class would stay the same (float: left;) and your .myform class would also stay the same (float: left;).
The .clear class takes care of helping the browser calculate the final display height and usually looks like:
.clear { clear: both; height: 1px; }
This is because you have <br>'s after your <div id="myform">.
first of all, there is some mistakes in your coding. Like
<div id='header'></a href='http://www.shoportrade.org/'><img src='mylogo1.png'></img></a>
should be
<div id='header'><a href='http://www.shoportrade.org/'><img src='mylogo1.png' /></a></div>
I believe you are declaring class myform in <style>, but I saw in your code you're trying to implement this <div id="myform">, which is totally wrong. It should be <div class="myform">. If you're actually want to implement different style for that div then I think you should use different id name like <div id='boxstyle'></div>
Here is a method without using floats. The heights of the two boxes will change depending on the container height.
If you want the heights of the boxes to be different, change their "bottom" value.
http://jsfiddle.net/Calum/m783T/
CSS
#container {
height: 500px;
width: 800px;
position: relative;
background-color: green;
}
#box, #box2 {
position: absolute;
top: 50px;
width: 200px;
}
#box {
background-color: blue;
left: 50px;
bottom: 50px;
}
#box2 {
background-color: red;
right: 50px;
bottom: 50px;
}
HTML
<div id="container">
<div id="box">
<p>This is box 1</p>
</div>
<div id="box2">
<p>This is box 2</p>
</div>
</div>

Continuing overflowed text in a different div?

What I am trying to do is create a site that displays my rants in faux letter form.
I want the "paper size" (div size) to be fixed, and the text to continue on the second piece of paper (a second div) displayed just below the first paper like this..
I apologize, being a new user, I am not allowed to post the
screenshots I have created to help explain my situation, so am forced
to link until I have enough reputation points:
http://img16.imageshack.us/img16/5538/pagesuc.jpg
ONLY FOR THE SAKE OF SIMPLICITY: I've created a simple html/css page to demonstrate in the simplest form what I am trying to accomplish with the code:
<style type="text/css">
* {
margin: 0;
padding: 0;
border: 0;
}
.container {
background: #FFFFFF;
width: 600px;
height: 400px;
margin: 0 auto;
}
#lbox {
background: #F00;
width: 300px;
height: 400px;
float: left;
}
#rbox {
background: #00F;
width: 300px;
height: 400px;
float: right;
}
.flowcontent {
padding: 10px 50px;
}
</style>
<div class="container">
<div id="lbox">
<div class="flowcontent">
<p>Lorem Ipsum...</p>
</div>
</div>
<div id="rbox">
<div class="flowcontent"> </div>
</div>
</div>
Screenshot:
I apologize, being a new user, I am not allowed to post the
screenshots I have created to help explain my situation, so am forced
to link until I have enough reputation points:
http://img689.imageshack.us/img689/7853/overflowc.jpg
In this case I would like the overflow from the red div to continue in the blue div on the right.
I realise this may not be possible with HTML/CSS alone, but was hoping maybe CSS3 might have some new tricks for this, as it has more advanced column handling.. If that's a no go, does anyone have a suggestion for a logical way to go about breaking this up using PHP or even JavaScript or JQuery?
I know PHP, but am still a JS/JQ newb so I have provided some (hopefully) very simple example code for anyone to plug in their own JS/PHP examples.
Anyway, thanks for your time.
I came up with a small JS Script that might help you out. It's far from perfect, but might give you a decent starting point. Essentially, it loops through your large text and looks for a scrollbar to appear. You may need to alter the calculations just a bit.
JSFiddle http://jsfiddle.net/Tt9sw/2/
JS
var currentCol = $('.col:first');
var text = currentCol.text();
currentCol.text('');
var wordArray=text.split(' ');
$.fn.hasOverflow = function() {
var div= document.getElementById($(this).attr('id'));
return div.scrollHeight>div.clientHeight;
};
for(var x=0; x<wordArray.length; x++){
var word= wordArray[x];
currentCol.append(word+' ');
if (currentCol.hasOverflow()){
currentCol = currentCol.next('.col');
}
}
HTML
<div class="col" id="col1">Lorem Ipsum ....... LONG TEXT .......</div>
<div class="col" id="col2"></div>
<div class="col" id="col3"></div>
<div class="col" id="col4"></div>
<div class="col" id="col5"></div>
CSS
.col{
width:200px;
float:left;
height:200px;
border:1px solid #999;
overflow:auto;
font-family:tahoma;
font-size:9pt;
}
UPDATE
For this example, you must include the jQuery Libray in your scripts.
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.3/jquery.min.js" type="text/javascript"></script>
PS - if you get to know jQuery, you will start to use it for everything. It greatly increases cross-browser compatibility and simplifies many common tasks.
What you want is CSS Regions module proposed by Adobe and currently supported by zero browsers. Adobe did release a very rough webkit-based browser for playing with the spec if you're really interested. But as others have said, right now you're SOL and will need to find another solution.
http://www.adobe.com/devnet/html5/articles/css3-regions.html
http://labs.adobe.com/technologies/cssregions/
http://dev.w3.org/csswg/css3-regions/
CSS3 has Multi-column Layout Module. However, I doubt it is widely supported to the moment.
Test it on your target browsers: http://www.quirksmode.org/css/multicolumn.html
You cannot do this with HTML and CSS only. CSS is targeted primarily at web browsers, and the layout model is that of a document on a vertically expanding surface. You can make boxes auto-height (which is the default), or fixed-height, but you cannot change the way content belongs to a parent box (which is what you would need for this to work).
A few options you could consider, if this is really important to you:
Use the paged-media features that are built into CSS to provide nice paging when rendered onto paged media (such as printouts); I'm talking about properties like page-break-after, page-break-before, etc. You won't get pages in a web browser, but at least you can control how it prints on physical paper
Write some incredible clever javascript that partitions your content into pages. There's a bit of a vicious circle here, because you won't know if your content fits until you try, so you may have to reflow several times in trial-and-error fashion. If your content has a special structure you can take advantage of, e.g. a poem form, where all line breaks are explicit, or if you use a fixed-width font, then a one-pass algorithm is possible, and you may even be able to do it server-side, using PHP, ASP.NET, or any other server-side scripting technology.
Use a different document format that gives you control over pages and absolute placement of elements within a page structure, e.g. PDF. (I wouldn't recommend using PDF for general web documents though; from a user's perspective, PDFs aren't convenient at all).
Use something like Flash or Silverlight to produce the desired layout. This, too, is something you should avoid unless there are other reasons why you'd be using it anyway; also, the formatting algorithm suffers from the same problems as a javascript implementation would, except that you have more control over the rendering part (fonts, kerning, etc.).
For most things on the web, however, I'd just let go of the idea and go with a more realizable design.
If you know how many characters one of your pages hold you can separate your string dynamically using javascript or php and then print the first part of the array in the first "paper sheet" and the second on the second.
You won't be able to do that with just HTML/CSS
Shapes by Adobe does exactly that, however, it has a very limited browser support.
IE: 11+
Chrome: 37+
FireFox: 32+

Best way to make an easy to edit "thermometer for donations"

I am trying to think of the best way to make a really small thermometer image, that can be easily edited by typing in a number (dollar value) and having the image change based on the value.
The simplest way to achieve this is the best. It will be going online onto a site that is using a CMS called spip.
Does anything small like this exist? and if i have to create it myself what's the best way to go about it?
The basic concept here is very simple; check out this fiddle. It's a basic nested div:
<div id='thermometer'>
<div id='level'>
</div>
</div>
which takes input from some form element:
<input type='text' id='fill'>
and some simple styling:
#thermometer { height: 15px; width: 100px; margin:5px; padding:0; border: #cccccc solid 1px; }
#level { height: 15px; width: 40px; margin: 0; padding:0; border-right: 1px solid #666666; background: #ffcccc; }
and a tiny bit of javascript:
$('#fill').keyup(function() {
$('#level').css('width',this.value);
});
Granted, this has no error checking, and could use a lot more work to make it robust, but it does what you ask it to do.
Layer two divs, each having part of the thermometer image, and hide parts of the red indicator bit div.
html 5 canvas + jquery or, a vary simple method will be to use divs, one on top of the other to simulate the thermometer levels. and simply change the background to red when the value increase or decrease
Something like this should work:
<?php
$goal = 100; // need to raise $100
$done = 78; // got $78 so far, e.g. 78% done
$full_size = '200'; // 200px
?>
<style type="text/css">
#thermometer {
width: <?php echo floor($full_size * ($done / $goal)) ?>px;
height: 1em;
color: red;
}
</style>
<div id="thermometer"></div>
Create a small text input form element that the user can enter a dollar amount into. Use jQuery and hook that element's onblur event, and within that hook, redraw the image as you want, scaling and all.
Don't have an example, but some simple steps for a PHP + CSS solution.
Use PHP to calculate the percentage of your goal met.
Use this percentage to calculate a CSS background-position property to show more or less of the thermometer background image by setting the style attribute inline with PHP.
UPDATE
For everyone that is gawking at doing this with PHP - how do you think JavaScript is getting the value to begin with? If PHP generates the page output and calculates the value, having PHP output the style directly is perfectly acceptable and keeps this at the source.

Categories