Answer the question
In order to leave comments, you need to log in
How to arrange pictures in a grid?
Hello, I have this code. Pictures are displayed in one column, it is necessary that there is a grid in 3 rows.
<?PHP
class main extends Core {
public function get_content (){
$query="SELECT a.id_photo, a.img_src, a.photo_name, b.id_user, b.name_user, b.id_user from t_photo as a, t_user as b where a.photo_name=b.id_user";
$result = mysql_query ($query);
if(!$result) {
exit (mysql_error () );
}
echo '<div class="content">';
$row = array ();
for ($i=0; $i < mysql_num_rows ($result); $i++) {
$row = mysql_fetch_array ($result, MYSQL_ASSOC);
echo '<div class="content_usr">';
printf ("<div style=';overflow: hidden; width:250px;'>
<div style='float:none;
border: 2px solid $55c5e9;
padding: 15px;
background:#666;
margin-right:0px;
margin-bottom:-10px;'><img src='%s' style='height:150px;'/><br> на фото: <b><a href='?option=view&id_user=%s'>%s</a></b></div></div>", $row ['img_src'],$row ['id_user'], $row ['name_user']); echo '</div>';
}echo '</div>';
}
}
?>
<meta http-equiv=content-type content="text/html; charset=utf-8" />
Answer the question
In order to leave comments, you need to log in
Write in divs with images style="float:left;"
and add after every 3rd image.
You can also use the value of the inline-block property display - read
1. It seems to me that you shouldn’t tag images too much - the best solution is to insert a real description of the image in the alt and title attributes
2. Use some js solution - for example
3. Write in .htaccess AddDefaultCharset UTF-8
and do it on utf-8 files without BOM
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question