I'm trying to display the data from the database, but whenever I connect it the whole page gets repeated - from the head title to a row and then it shows the head title again as if I had split the page, and another row from the database.
I want to show the data like the products page next to each other but it only shows one and then repeats the whole page.
This is my code that I tried - the page gets repeated from the main-container and shows one row, then repeats the main container again.
<?php
require_once 'opp_data.php';
$sql ="SELECT * FROM college_opp";
$allopp =$conn->query($sql);
?>
//i dont know if i have to show the whole code but this is only the code part where everything gets repeated
<?php
while ($row = mysqli_fetch_assoc($allopp)) {
?>
<div class="main-container">
<h2>تصفح الفرص التطوعية </h2>
<div class="post-collect">
<div class="post-main-container">
<div class="all sports">
<div class="post-img">
<img src="imgs/<?php echo $row["images"]; ?>">
<span class="category-name" data-name="sporty">كلية علوم الرياضة </span>
</div>
<div class="post-content">
<div class="post-content-top">
<span>
<i class="fa-solid fa-users-line"></i><?php echo $row["volunteer_num"]; ?>
</span>
<span><i class="fa-regular fa-calendar-days"></i><?php echo $row["Date"]; ?></span>
</div>
<h2>"<?php echo $row["Title"]; ?>"</h2>
<p>"<?php echo $row["Description"]; ?>"</p>
</div>
<div class="button-btn">
التفاصيل والتسجيل
</div>
</div>
</div>
</div>
</div>
<?php
}
?>
</body>
for the style.css\\
.main-container{
width: 90vw;
margin: 0 auto;
padding: 40px 0;
}
.main-container h2{
text-align: center;
padding: 90px 0;
font-size: 32px;
color: #fff;
}
.main-container p{
font-weight: 300;
padding: 10px 0;
opacity: 0.7;
text-align: center;
}
.post-main-container{
display: grid;
grid-template-columns: repeat(4, 1fr);
grid-gap: 60px;
}
.post-main-container div{
box-shadow: 0px 8px 27px -12px rgba(0, 0, 0, 0.64);
}
.post-img{
position: relative;
width: 2vw;
height: 19vw;
}
.post-img img{
position: absolute;
left: 20px;
width: 17vw;
height: 19vw;
}
.post-content{
padding: 25px;
}
.post-content-top{
background: #2b1055;
color: #fff;
opacity: 0,9;
padding: 5px 0 5px 15px;
}
.post-content-top span{
padding-right: 20px;
}
.post-content h2{
font-size: 22px;
padding: 12px 0;
font-weight: 400;
}
.post-content p{
opacity: 0.7;
font-size: 15px;
line-height: 1.8;
color: ghostwhite;
}
.button-btn a {
padding: 8px 15px;
display: block;
font-family:'Almarai', sans-serif ;
font-size: 15px;
cursor: pointer;
background: transparent;
border-radius: 20px;
width: 50%;
border: 2px solid #fff;
color: #fff;
margin: 5px auto;
padding: 0.4rem;
text-decoration: none;
font-weight: 600;
transition: all 0.2s ease-in-out;
}
.button-btn a:hover{
background:#2b1055;
}
Because your entire page is in the while loop it will duplicate the whole page multiple times. I don't know if this is exactly what you want but I suggest you doing it something like this:
<?php
require_once 'opp_data.php';
$sql ="SELECT * FROM college_opp";
$allopp =$conn->query($sql);
?>
<div class="main-container">
<h2>تصفح الفرص التطوعية </h2>
<div class="post-collect">
<?php while ($row = mysqli_fetch_assoc($allopp)) { ?>
<div class="post-main-container">
<div class="all sports">
<div class="post-img">
<img src="imgs/<?php echo $row[" images "]; ?>">
<span class="category-name" data-name="sporty">كلية علوم الرياضة </span>
</div>
<div class="post-content">
<div class="post-content-top">
<span>
<i class="fa-solid fa-users-line"></i><?php echo $row["volunteer_num"]; ?>
</span>
<span><i class="fa-regular fa-calendar-days"></i><?php echo $row["Date"]; ?></span>
</div>
<h2>"
<?php echo $row["Title"]; ?>"</h2>
<p>"
<?php echo $row["Description"]; ?>"</p>
</div>
<div class="button-btn">
التفاصيل والتسجيل
</div>
</div>
</div>
<?php } ?>
</div>
</div>
This will only loop the post-main-container.
This is the code you are looking for
<div class="main-container">
<h2>تصفح الفرص التطوعية </h2>
<div class="post-collect">
<div class="post-main-container">
<?php
while ($row = mysqli_fetch_assoc($allopp)) {
?>
<div class="all sports">
<div class="post-img">
<img src="imgs/<?php echo $row["images"]; ?>">
<span class="category-name" data-name="sporty">كلية علوم الرياضة </span>
</div>
<div class="post-content">
<div class="post-content-top">
<span>
<i class="fa-solid fa-users-line"></i><?php echo $row["volunteer_num"]; ?>
</span>
<span>
<i class="fa-regular fa-calendar-days"></i><?php echo $row["Date"]; ?>
</span>
</div>
<h2>"<?php echo $row["Title"]; ?>"</h2>
<p>"<?php echo $row["Description"]; ?>"</p>
</div>
<div class="button-btn">
التفاصيل والتسجيل
</div>
</div>
<?php
}
?>
</div>
</div>
</div>
Related
I am working on a responsive website,
Here i have 4 divs inside a main div.
On desktop fullscreen you will see the 4 divs next to eachother
But once the screen goes below 1025px it should
Be 2 divs next to eachother and 2 divs below that ( 2x2 )
but once it goes below 1025px it keeps the main styling aswell and the blocks are still 4 wide
.grid-wide-4-block-main {
margin-left: auto;
margin-right: auto;
}
.grid-wide-4-block {
display: flex;
justify-content: space-around;
height: 1000px;
max-width: auto;
width: auto;
margin: auto;
max-width: 1620px;
}
.grid-wide-logo {
height: 50px;
width: 50px;
margin-left: 10px;
margin-top: 10px;
}
.grid-wide-4-blocks {
min-width: 20%;
margin-left: 3%;
margin-right: 3%;
height: 400px;
background-color: white;
box-shadow: 0 0.2rem 0.4rem rgb(0 0 0 / 10%), 0 0.67rem 2rem rgb(0 0 0 / 10%);
}
.grid-wide-4-block-inside {
margin: 5px;
}
.grid-wide-4-title {
color: orange;
}
#media screen and (max-width: 1025px) {
.grid-wide-4-block {
max-width: 1025px;
height: 1000px;
}
.grid-wide-4-blocks {
min-width: 45%;
height: 40%;
background-color: white;
box-shadow: 0 0.2rem 0.4rem rgb(0 0 0 / 10%), 0 0.67rem 2rem rgba(171, 77, 40, 0.1);
}
}
<div class="grid-wide-4-block-main">
<div class="grid-wide-4-block">
<?php echo $background; ?>
<div class="grid-wide-4-block-1 grid-wide-4-blocks">
<div class="grid-wide-4-block-inside">
<?php if ($grid_wide_4_imageObj) : ?>
<img class="grid-wide-4-image-1 grid-wide-logo" src="<?php echo $grid_wide_4_image_url; ?>" />
<?php endif; ?>
<h3 class="grid-wide-4-title">
<?php echo $grid_wide_4_title; ?>
</h3>
<p class="grid-wide-4-summary-1">
<?php echo $grid_wide_4_summary; ?>
</p>
</div>
</div>
<div class="grid-wide-4-block-2 grid-wide-4-blocks">
<div class="grid-wide-4-block-inside">
<?php if ($grid_wide_4_imageObj2) : ?>
<img class="grid-wide-4-image-2 grid-wide-logo" src="<?php echo $grid_wide_4_image_url2; ?>" />
<?php endif; ?>
<h3 class="grid-wide-4-title">
<?php echo $grid_wide_4_title2; ?>
</h3>
<p class="grid-wide-4-summary-2">
<?php echo $grid_wide_4_summary2; ?>
</p>
</div>
</div>
<div class="grid-wide-4-block-3 grid-wide-4-blocks">
<div class="grid-wide-4-block-inside">
<?php if ($grid_wide_4_imageObj3) : ?>
<img class="grid-wide-4-image-3 grid-wide-logo" src="<?php echo $grid_wide_4_image_url3; ?>" />
<?php endif; ?>
<h3 class="grid-wide-4-title">
<?php echo $grid_wide_4_title3; ?>
</h3>
<p class="grid-wide-4-summary-3">
<?php echo $grid_wide_4_summary3; ?>
</p>
</div>
</div>
<div class="grid-wide-4-block-4 grid-wide-4-blocks">
<div class="grid-wide-4-block-inside">
<?php if ($grid_wide_4_imageObj4) : ?>
<img class="grid-wide-4-image-4 grid-wide-logo" src="<?php echo $grid_wide_4_image_url4; ?>" />
<?php endif; ?>
<h3 class="grid-wide-4-title">
<?php echo $grid_wide_4_title4; ?>
</h3>
<p class="grid-wide-4-summary-4">
<?php echo $grid_wide_4_summary4; ?>
</p>
</div>
</div>
</div>
</div>
.grid-wide-4-block {
box-sizing: border-box;
display: flex;
flex-direction: column;
flex-wrap: wrap;
max-width: 1025px;
height: 1000px;
}
.grid-wide-4-blocks {
max-width: 45%;
height: 400px;
background-color: white;
box-shadow: 0 0.2rem 0.4rem rgb(0 0 0 / 10%), 0 0.67rem 2rem rgba(171, 77, 40, 0.1);
}
this should work
my columns are not behaving and are all squashed to the left, i've tried overriding the col-2 to set no margins or flex and nothing works, any ideas? thanks.
<li>
<div class="link"><i class="fa fa-database"></i>More<i class="fa fa-chevron-down"></i></div>
<ul>
<?php foreach ($Ranking as $post): ?>
<div class="row" style="margin: 0px 30px;">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<div class="col-2">
<h4 style="font-weight: 500;"><a
href="/single_page_main.php?id=<?php echo $post['id']; ?>"><?php echo $post['title']; ?>
</a></h4>
</div>
<div class="col-2">
<h4><?php echo html_entity_decode($post['body']); ?></h4>
</div>
<div class="col-4">
<img src="<?php echo '/assets/images/' ,
$post['image']; ?>">
</div>
<div class="col-4">
<a href="/player_profile.php?id=<?php echo $post['id']; ?>"><div class="">Profile</div>
</a>
</div>
</div>
</div>
<?php endforeach; ?>
</ul>
</li>
</ul>
$(function() {
var Accordion = function(el, multiple) {
this.el = el || {};
this.multiple = multiple || false;
var links = this.el.find('.link');
links.on('click', {el: this.el, multiple: this.multiple},
this.dropdown)
}
Accordion.prototype.dropdown = function(e) {
var $el = e.data.el;
$this = $(this),
$next = $this.next();
$next.slideToggle();
$this.parent().toggleClass('open');
if (!e.data.multiple) {
$el.find('.submenu').not($next).slideUp().parent().removeClass('open');
};
}
var accordion = new Accordion($('#accordion'), false);
});
The above is the jquery accordion code used to show the ul content on click, however all the conent within this has been moved to the left and none of it centres even with overriding css styles or html code, any ideas? thanks.
.accordion {
width: 100%;
margin: 30px auto 20px;
background: #FFF;
max-width: 800px;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
}
.accordion .link {
cursor: pointer;
display: block;
padding: 15px 15px 15px 42px;
color: #4D4D4D;
font-size: 14px;
font-weight: 700;
border-bottom: 1px solid #CCC;
position: relative;
-webkit-transition: all 0.4s ease;
-o-transition: all 0.4s ease;
transition: all 0.4s ease;
}
Above is the CSS, thanks.
I get this
I'm trying to achieve this
i will need some help with some coding if possible. I would like to have when clicked Learn More to show description above the button and when clicked back to hide it. Any help would be higly appreciated! Code listed below. Thank you for your time!
One more thing, as you can see the top border is not shown, how can i make it to show? Thank you very much for the time spent!
<style>
/* RELATE PRODUCTS BEGIN */
.cardd {
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
max-width: 600px;
margin: auto;
text-align: center;
font-family: arial;
}
.cardd p {
font-family: "Arial Black", Gadget, sans-serif;
font-size: 24px;
font-weight: bold;
margin-top: 6px;
margin-bottom: 5px;
margin-left: 0px;
text-align: left;
padding-top: 6px;
}
.price {
color: grey;
font-size: 22px;
}
.cardd button {
border: none;
outline: 0;
padding: 12px;
color: white;
background-color: #c41735;
text-align: center;
cursor: pointer;
width: 100%;
font-size: 18px;
}
.cardd button:hover {
opacity: 0.7;
}
hr {
display: block;
height: 1px;
border: 0;
border-top: 1px solid #ccc;
padding: 0;
margin-top: 0px;
margin-bottom: 10px;
}
</style>
<div class="container">
<!-- <div class="row no-margin">
<div class="col-lg-12 text-center">
<h1 class="section-heading">Harnesses</h1>
</div>
</div> -->
<div class="row">
<div class="col-lg-12 scrollReveal sr-bottom sr-ease-in-out-quad sr-delay-1">
<br><br><br>
<h1 class="section-heading page-heading">Engines</h1>
<p></p>
</div>
</div>
<div class="height-60"> </div>
<div class="row">
<div class="col-lg-3 col-md-6 mb-5 col-sm-12">
<div class="scrollReveal sr-bottom sr-ease-in-out-quad sr-delay-1 ">
<div class="cardd">
<img src="g" alt="" style="width:100%">
<h2 class="page-heading">Vittorazi<br> Moster185 Plus MY20</h1>
<span class="price">£1729.99</span>
<p></p>
<p><button>Learn more</button></p>
<p></p>
</div>
</div>
</div> <br>
<div class="col-lg-3 col-md-6 mb-5 col-sm-12">
<div class="scrollReveal sr-bottom sr-ease-in-out-quad sr-delay-1">
<div class="cardd">
<img src="g" alt="" style="width:100%">
<h2 class="page-heading"><br> </h1>
<span class="price">£1729.99</span>
<p></p>
<p><button>Learn more</button></p>
</div>
</div>
</div> <br>
<div class="col-lg-3 col-md-6 mb-5 col-sm-12">
<div class="scrollReveal sr-bottom sr-ease-in-out-quad sr-delay-1">
<div class="cardd">
<img src="" alt="" style="width:100%">
<h2 class="page-heading"><br> </h1>
<span class="price">£1729.99</span>
<p></p>
<p><button>Learn more</button></p>
</div>
</div>
</div> <br>
<div class="col-lg-3 col-md-6 mb-5 col-sm-12">
<div class="scrollReveal sr-bottom sr-ease-in-out-quad sr-delay-1">
<div class="cardd">
<img src="" alt="Atom 80 Vitorazzi" style="width:100%">
<h2 class="page-heading"><br></h1>
<span class="price">£1729.99</span>
<p></p>
<p><button>Learn more</button></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
What you're looking for is a collapsible! All you need is a little JavaScript, and you can expand/collapse text using a button.
Expand Above
If you want to make the hidden text appear above the button, try this:
var collapse = document.getElementsByClassName("collapsible");
var i;
for (i = 0; i < collapse.length; i++) {
collapse[i].addEventListener("click", function() {
this.classList.toggle("active");
var expand = this.previousElementSibling;
if (expand.style.display === "block") {
expand.style.display = "none";
} else {
expand.style.display = "block";
}
});
}
.collapsible {
border: none;
outline: 0;
padding: 12px;
color: white;
background-color: #c41735;
text-align: center;
cursor: pointer;
width: 100%;
font-size: 18px;
}
.expand {
padding: 0 18px;
display: none;
overflow: hidden;
background-color: #eee;
}
<div class="expand">
<p>
Hidden text.
</p>
</div>
<button type="button" class="collapsible">Learn more</button>
Expand Below
If you want to make it appear below the button, however, just flip the order in which the <div> and <button> element appear, and switch out previousElementSibling with nextElementSibling:
var collapse = document.getElementsByClassName("collapsible");
var i;
for (i = 0; i < collapse.length; i++) {
collapse[i].addEventListener("click", function() {
this.classList.toggle("active");
var expand = this.nextElementSibling;
if (expand.style.display === "block") {
expand.style.display = "none";
} else {
expand.style.display = "block";
}
});
}
.collapsible {
border: none;
outline: 0;
padding: 12px;
color: white;
background-color: #c41735;
text-align: center;
cursor: pointer;
width: 100%;
font-size: 18px;
}
.expand {
padding: 0 18px;
display: none;
overflow: hidden;
background-color: #eee;
}
<button type="button" class="collapsible">Learn more</button>
<div class="expand">
<p>
Hidden text.
</p>
</div>
To make the text hide and appear above the Button you must make use of toggle() event as
$("document").ready(function(){
$(".collapsible").toggle(
function(){
$(".expand").css({"display" : "block"});},
function(){
$(".expand").css({"display" : "none"});});
});
.collapsible {
border: none;
outline: 0;
padding: 12px;
color: white;
background-color: #c41735;
text-align: center;
cursor: pointer;
width: 100%;
font-size: 18px;
}
.expand {
padding: 0 18px;
display: none;
overflow: hidden;
background-color: #eee;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js"></script>
<div class="expand">
<p>
Hidden text.
</p>
</div>
<button type="button" class="collapsible">Learn more</button>
Note: Add the Jquery CDN to use the jquery code.
(<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js">
</script>)
I looked up online and didn't find the answer. English is my second language, so I think I'm not looking with the good words. I have a search engine on my website and I want to have a "bump" effect when I hover a result. The problem is, when I hover a result, it affects all of them simultaneously.
HTML-PHP
while ($row = mysql_fetch_assoc($getquery)) {
$id = $row['ID'];
$input1 = $row['name'];
echo '<div class="foo">';
echo '<div class="fooimage">';
echo "<a href='details.php?id=$id'> <img alt='Image goes here' src='portal_user/submit_form/" . $row["Photos"] . "' width=190px height=140px></a>";
echo '</div>';
echo '<div class="footext">';
echo "<div class='input1'>";
echo "<a href='details.php?id=$id'>$input1</a>";
echo "</div>";
echo "</div>";
echo "</div>";
}
CSS
.foo {
position: relative;
height: 205px;
width: 200px;
display: inline-block;
background-color: #ececec;
margin-left: 20px;
margin-bottom: 10px;
margin-top: 0px;
box-shadow: 5px 5px 3px #888888;
transition: .7s
}
.foo:hover {
margin-bottom: 10px;
margin-top: -5px;
}
I want to have the bump effect on the foo div. The results need to stay inline-block to have them in rows and not one on top of the other.
You'll need a little jQuery help here I think. I also changed the CSS a little bit, but adjust as necessary:
$( ".foo" ).hover(
function() {
$(this ).addClass('hover');
}, function() {
$( this ).removeClass('hover');
}
);
.foo {
position: relative;
top: 0;
height: 205px;
width: 200px;
display: inline-block;
background-color: #ececec;
margin-left: 20px;
margin-bottom: 10px;
margin-top: 0px;
box-shadow: 5px 5px 3px #888888;
transition: .7s
}
.foo.hover {
position: relative;
top: -10px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="foo">
<div class="fooimage">
<a href='details.php?id=$id'>
<img alt='Image goes here' src='http://placehold.it/190x140' width=190px height=140px>
</a>
</div>
<div class="footext">
<div class='input1'>
<a href='#'>$input1</a>
</div>
</div>
</div>
<div class="foo">
<div class="fooimage">
<a href='details.php?id=$id'>
<img alt='Image goes here' src='http://placehold.it/190x140' width=190px height=140px>
</a>
</div>
<div class="footext">
<div class='input1'>
<a href='#'>$input1</a>
</div>
</div>
</div>
<div class="foo">
<div class="fooimage">
<a href='details.php?id=$id'>
<img alt='Image goes here' src='http://placehold.it/190x140' width=190px height=140px>
</a>
</div>
<div class="footext">
<div class='input1'>
<a href='#'>$input1</a>
</div>
</div>
</div>
This menu is made in html and php. I have a menu in css. Whenever I mouse over on menu item it doesn't make a link on mouseover, and whenever I click on text it make a link.
<div class="panel panel-default">
<div class="panel-heading">
<?php if($menurow['hassubmenu'] != NULL)
{?>
<a data-toggle="collapse" data-parent="#accordian" href="#<?php echo $menurow['mainmenuid']; ?>" title="<?php echo $menurow['title']; ?>"><span class="badge pull-right"><i class="fa fa-plus"></i></span><?php echo $menurow['title']; ?></a>
<?php }else{?>
<h4 class="panel-title"><?php echo $menurow['title']; ?></h4>
<?php } ?>
</div>
<?php if($menurow['hassubmenu'] != NULL){?>
<div id="<?php echo $menurow['mainmenuid']; ?>" class="panel-collapse collapse">
<div class="panel-body">
<ul>
<?php
$menuquery2 = mysql_query("select title,itemid,catid from submenu where mainmenuid=".$menurow['mainmenuid']." order by sort asc");
while($menurow2 = mysql_fetch_assoc($menuquery2))
{
if($menurow2['itemid'] != NULL)
$menulink2 = "showitem.php?id=".$menurow2['itemid'];
elseif($menurow2['catid'] != NULL)
$menulink2 = "category.php?id=".$menurow2['catid'];
else
$menulink2 = "#";
?>
<li><?php echo $menurow2['title']; ?></li>
<?php }?>
</ul>
</div>
</div>
<?php }?>
</div>
CSS Code
/* New menu */
.category-products .panel {
background-color: #FFFFFF;
border: 0px;
border-radius: 0px;
box-shadow:none;
margin-bottom: 0px;
}
.category-products .panel-default .panel-heading {
background-color: #CCCCCC;
border: 1px solid;
color: #FFFFFF;
padding: 5px 20px;
cursor:pointer;
height:40px;
}
.category-products .panel-default .panel-heading a { color: #D00233;
font-family: 'Roboto', sans-serif;
font-size: 14px;
text-decoration: none;
text-transform: uppercase;
}
.category-products .panel-default .panel-heading a:hover {background:#D00233; color:#fff;}
.category-products .panel-default .panel-heading:hover {background:#D00233; color:#fff !important;}
.category-products .panel-default .panel-heading .panel-title {
color: #D00233;
font-family: 'Roboto', sans-serif;
font-size: 14px;
text-decoration: none;
text-transform: uppercase;
}
.category-products .panel-default .panel-heading .panel-title:hover {color:#fff;background:#D00233;}
Please help me.
add this to the links and to the panel-title:
display: block;
width: 100%;
height: 100%;
in your case that would be:
.panel-title{
display: block;
width: 100%;
height: 100%;
}
.panel-title>a{
display: block;
width: 100%;
height: 100%;
}