I have a video as background so I want only the content of the page to load since everything else is the same. I tried using Ajax, but I couldn't get it to work. Is there a way to achieve that ?
Layout code:
/...
<body>
<video autoplay loop poster="/img/bg-still.png" preload="auto" id="bg">
<source src="/img/bg.webm" type="video/webm">
</video>
<div id="wrapper">
<header>
<div class="top_line">
<div class="container">
<div class="row">
<?php
if ($user = $this->identity()) {
?>
<div class="col-lg-6 pull-left">
<p>
<span class="welcome-show">Здравей, <?php echo $this->EscapeHtml($user->nick) ?></span>
<span class="rank">Ранк:
<?php
switch ($user->role) {
case 1:
?> <span class="rank-vip">VIP</span> <?php
break;
case 2:
?> <span class="rank-vipplus">VIP+</span> <?php
break;
default:
?> <span class="rank-none">Никакъв</span> <?php
break;
}
?>
</span>
<span class="credits-show">Кредити: <?php echo $this->EscapeHtml($user->credits) ?></span>
<img src="/img/ui-icon-credits" class="ui-icon-credits"/>Заредете кредити
<a href="/edit" class="register"><span
class="icon icon-settings ui-icon ui-icon-gear"></span>Настройки</a>
<a href="/logout" class="register"><span
class="icon icon-logout ui-icon ui-icon-close"></span>Излез</a>
</p>
</div>
<?php
} else {
?>
<div class="col-lg-6 pull-left">
<p>
<span class="icon icon-login ui-icon ui-icon-key"></span>Влез
<a href="/register" class="register"><span
class="icon icon-register ui-icon ui-icon-person"></span>Регистрирай се</a>
</p>
</div>
<?php
}
?>
</div>
</div>
</div>
</header>
<div class="page_head">
<div class="nav-container" style="height: auto;">
<nav>
<div class="container">
<div class="row">
<div class="col-lg-3 pull-left">
<a href="/">
<div class="logo"></div>
</a>
<div class="beta">BETA</div>
</div>
<div class="col-lg-9 pull-right">
<div class="menu">
<div id="dl-menu" class="dl-menuwrapper">
<button class="dl-trigger">Open Menu</button>
<?php
echo $this->navigation('navigation')->menu();
?>
</div>
</div>
</div>
</div>
</div>
</nav>
</div>
</div>
<div class="content" id="content">
<?php echo $this->content; ?>
</div>
<div class="footer">
/...
Related
I have a little problem that might be syntax (since I'm not that good at php). Basically, I'm de-wrapping a code where there will be records where there will be a date (in this case, a foundation date, for example; 20-08-2027). So I created an "if". If there are records with the date, for example, 2027, the records appear. If there is not, then an error message will be displayed saying that there is still no record made with that date. I've tried a few things, but nothing worked. At this point, an error appears. Below will be the error. Please try to help me. It's no use saying more technical things, because I'm not that good at php. Thank you.
Error: "Parse error: syntax error, unexpected 'else' (T_ELSE) in /home/host/public_html/template/year/2027.php on line 300"
2027.php
<section class="content products">
<div class="container">
<h1 class="hidden">Eventos</h1>
<div class="row">
<div class="col-sm-10">
<div class="row grid" id="products">
<div class="releated-products">
<div class="row grid" id="products">
<?php
$sqli=sprintf("SELECT * FROM eventos WHERE YEAR(data) = 2027");
$resu=mysqli_query($con,$sqli);
mysqli_set_charset($con, 'UTF8');
if (mysqli_num_rows($resu)>0) {
while($regi=mysqli_fetch_array($resu)){
$sqli_consulta=sprintf("select * from eventos where id=%d;",$regi['id']);
$resu_consulta=mysqli_query($con,$sqli_consulta);
$regi_consulta=mysqli_fetch_array($resu_consulta);
$linkk='../eventoindividual.php?id='.$regi_consulta['id'];
?>
<div class="col-sm-3 col-xs-6">
<article class="product-item">
<div class="row">
<div class="col-sm-3">
<div class="product-overlay">
<div class="product-mask"></div>
<img src="<?php echo '../admin/documentos/'.$regi['nome_doc']; ?>" style="width:100%">
</div>
</div>
<div class="col-sm-9">
<div class="product-body">
<h3><?php echo $regi['nome']; ?></h3>
<br>
<span class="price">
<ins><span class="amount"><?php echo $regi['preco']; ?></span></ins>
</span>
<div class="buttons buttons-simple">
<i class="fa fa-shopping-cart"></i>Comprar bilhetes
</div>
</div>
</div>
</div>
</article>
</div>
<?php
} else{
?>
<p>Nada!</p>
<?php
}
}
?>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
The reason you are getting the error because you have while loop in your if block that you are not closing.
Check the code below for this fixed version.
<?php
$sqli=sprintf("SELECT * FROM eventos WHERE YEAR(data) = 2027");
$resu=mysqli_query($con,$sqli);
mysqli_set_charset($con, 'UTF8');
if (mysqli_num_rows($resu)>0):
while($regi=mysqli_fetch_array($resu)):
$sqli_consulta=sprintf("select * from eventos where id=%d;",$regi['id']);
$resu_consulta=mysqli_query($con,$sqli_consulta);
$regi_consulta=mysqli_fetch_array($resu_consulta);
$linkk='../eventoindividual.php?id='.$regi_consulta['id'];
?>
<div class="col-sm-3 col-xs-6">
<article class="product-item">
<div class="row">
<div class="col-sm-3">
<div class="product-overlay">
<div class="product-mask"></div>
<img src="<?php echo '../admin/documentos/'.$regi['nome_doc']; ?>" style="width:100%">
</div>
</div>
<div class="col-sm-9">
<div class="product-body">
<h3><?php echo $regi['nome']; ?></h3>
<br>
<span class="price">
<ins><span class="amount"><?php echo $regi['preco']; ?></span></ins>
</span>
<div class="buttons buttons-simple">
<i class="fa fa-shopping-cart"></i>Comprar bilhetes
</div>
</div>
</div>
</div>
</article>
</div>
<?php endwhile; else: ?>
<p>Nada!</p>
<?php
endif;
?>
Move the last } bracket above }else{
<section class="content products">
<div class="container">
<h1 class="hidden">Eventos</h1>
<div class="row">
<div class="col-sm-10">
<div class="row grid" id="products">
<div class="releated-products">
<div class="row grid" id="products">
<?php
$sqli=sprintf("SELECT * FROM eventos WHERE YEAR(data) = 2027");
$resu=mysqli_query($con,$sqli);
mysqli_set_charset($con, 'UTF8');
if (mysqli_num_rows($resu)>0) {
while($regi=mysqli_fetch_array($resu)){
$sqli_consulta=sprintf("select * from eventos where id=%d;",$regi['id']);
$resu_consulta=mysqli_query($con,$sqli_consulta);
$regi_consulta=mysqli_fetch_array($resu_consulta);
$linkk='../eventoindividual.php?id='.$regi_consulta['id'];
?>
<div class="col-sm-3 col-xs-6">
<article class="product-item">
<div class="row">
<div class="col-sm-3">
<div class="product-overlay">
<div class="product-mask"></div>
<img src="<?php echo '../admin/documentos/'.$regi['nome_doc']; ?>" style="width:100%">
</div>
</div>
<div class="col-sm-9">
<div class="product-body">
<h3><?php echo $regi['nome']; ?></h3>
<br>
<span class="price">
<ins><span class="amount"><?php echo $regi['preco']; ?></span></ins>
</span>
<div class="buttons buttons-simple">
<i class="fa fa-shopping-cart"></i>Comprar bilhetes
</div>
</div>
</div>
</div>
</article>
</div>
<?php
} // while()
} else{
?>
<p>Nada!</p>
<?php
}
// } //wrong bracket
?>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
For your own sanity it is a good idea leave a comment after closing bracket of a long code, so you know which block it belongs to.
Compiler can't be wrong, if it says there's syntax error then there is. The bracket before the else is closing the while loop - hence else cannot be used there, close the if condition. Here's the corrected code:
<section class="content products">
<div class="container">
<h1 class="hidden">Eventos</h1>
<div class="row">
<div class="col-sm-10">
<div class="row grid" id="products">
<div class="releated-products">
<div class="row grid" id="products">
<?php
$sqli=sprintf("SELECT * FROM eventos WHERE YEAR(data) = 2027");
$resu=mysqli_query($con,$sqli);
mysqli_set_charset($con, 'UTF8');
if (mysqli_num_rows($resu)>0) {
while($regi=mysqli_fetch_array($resu)) {
$sqli_consulta=sprintf("select * from eventos where id=%d;",$regi['id']);
$resu_consulta=mysqli_query($con,$sqli_consulta);
$regi_consulta=mysqli_fetch_array($resu_consulta);
$linkk='../eventoindividual.php?id='.$regi_consulta['id'];
/* 2 brackets { */
?>
<div class="col-sm-3 col-xs-6">
<article class="product-item">
<div class="row">
<div class="col-sm-3">
<div class="product-overlay">
<div class="product-mask"></div>
<img src="<?php echo '../admin/documentos/'.$regi['nome_doc']; ?>" style="width:100%">
</div>
</div>
<div class="col-sm-9">
<div class="product-body">
<h3><?php echo $regi['nome']; ?></h3>
<br>
<span class="price">
<ins><span class="amount"><?php echo $regi['preco']; ?></span></ins>
</span>
<div class="buttons buttons-simple">
<i class="fa fa-shopping-cart"></i>Comprar bilhetes
</div>
</div>
</div>
</div>
</article>
</div>
<?php
} // while loop
} // if condition
else {
?>
<p>Nada!</p>
<?php
}
?>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
hope this helps. 👍
I have written some code for displaying a particular div in html. The code is shown below :
<div id="pdfdiv_1">
<section class="report">
<div class="top-box"></div>
<div class="row">
<div class="col-md-12 text-center">
<img src="<?php echo base_url()?>reports-assets-new/images/banner.png" class="bannerimg" style="
width: auto;">
</div>
<div class="col-md-5">
<div class="info-wrapper">
<?php if(!empty($user_details->st_profile)){ ?>
<img src="<?php echo base_url();?>uploads/user-profile/<?php echo $user_details->st_profile;?>" style="width: 22%;">
<?php } else {?>
<img src="<?php echo base_url()?>reports-assets-new/images/img2.png">
<?php } ?>
<div class="info-wrap-inner">
<p><span>Name </span> : <?php echo $user_details->st_name;?></p>
<p><span>Age </span> : <?php echo $age;?></p>
<p><span>Education </span> : <?php echo $user_details->st_qualification;?></p>
<p><span>Mobile </span> : <?php echo $user_details->st_mobile;?></p>
<p><span>Email </span> : <?php echo $user_details->st_email;?></p>
<p><span>Date of test </span> : <?php $s=$user_details->c_date; $dt = new DateTime($s); $date = $dt->format('d-m-Y'); echo $date; ?></p>
</div>
</div>
</div>
<div class="col-md-7 report-wrapper">
<h1 class="heading">SKILL FINDER TEST REPORT</h1>
<p><?php echo $test_details->description;?></p>
</div>
</div>
</div>
</section>
<section class="skills">
<div class="container">
<div class="row">
<div class="col-md-12">
<h1><span>IDENTIFY SKILLS BASED ON YOUR INTERESTS</span></h1>
</div>
</div>
<div class="row">
<?php echo $test_details->description3;?>
</div>
</section>
</div><!-- pdfdiv close -->
I have written a code for displaying the div pdfdiv_1 in jquery as shown below :
<script>
function pdfP(exam_id,test_id,base_url) {
var test = document.getElementById('pdfdiv_1').innerHTML;
console.log(test);
$.ajax({
type: 'POST',
data: {test : test,exam_id:exam_id,test_id:test_id},
url: base_url+"reports/reports_pdf_new/skill_finder",
success: function (data) {
window.location.href = base_url+"reports_pdf_new/"+exam_id+"/"+test_id;
},
});
}
</script>
When I am printing the console output, it is only printing the first section part but not the second section tag.
The output in console is :
<section class="report">
<div class="top-box"></div>
<div class="row">
<div class="col-md-12 text-center">
<img src="<?php echo base_url()?>reports-assets-new/images/banner.png" class="bannerimg" style="
width: auto;">
</div>
<div class="col-md-5">
<div class="info-wrapper">
<?php if(!empty($user_details->st_profile)){ ?>
<img src="<?php echo base_url();?>uploads/user-profile/<?php echo $user_details->st_profile;?>" style="width: 22%;">
<?php } else {?>
<img src="<?php echo base_url()?>reports-assets-new/images/img2.png">
<?php } ?>
<div class="info-wrap-inner">
<p><span>Name </span> : <?php echo $user_details->st_name;?></p>
<p><span>Age </span> : <?php echo $age;?></p>
<p><span>Education </span> : <?php echo $user_details->st_qualification;?></p>
<p><span>Mobile </span> : <?php echo $user_details->st_mobile;?></p>
<p><span>Email </span> : <?php echo $user_details->st_email;?></p>
<p><span>Date of test </span> : <?php $s=$user_details->c_date; $dt = new DateTime($s); $date = $dt->format('d-m-Y'); echo $date; ?></p>
</div>
</div>
</div>
<div class="col-md-7 report-wrapper">
<h1 class="heading">SKILL FINDER TEST REPORT</h1>
<p><?php echo $test_details->description;?></p>
</div>
</div>
</div>
</section>
Can anyone help me out in this ?
I cant print all the html code present inside the div pdfdiv_1.
The html code :
<div class="download-pdf">
<div class="row">
<div class="col-12">
<div class="card p-4 mt-0">
<h2 class="text-center mb-0">Congratulations!</h2>
<p class="lead text-center" style="margin-top: -18px">
<br>
<div class="button-wrapper" style="text-align: center;">
<button onclick="pdfP(<?php echo $exam_id;?>,<?php echo $test_id;?>,'<?php echo base_url();?>')" class="btn btn-primary d-block mx-auto">Download PDF</button>
<span id="pdfloader"></span>
</div>
</div>
</div>
</div>
</div>
There are some mistakes on html tags placement.
This code might fix them :
<div id="pdfdiv_1">
<section class="report">
<div class="top-box"></div>
<div class="row">
<div class="col-md-12 text-center">
<img src="<?php echo base_url()?>reports-assets-new/images/banner.png" class="bannerimg" style="
width: auto;">
</div>
<div class="col-md-5">
<div class="info-wrapper">
<?php if(!empty($user_details->st_profile)){ ?>
<img src="<?php echo base_url();?>uploads/user-profile/<?php echo $user_details->st_profile;?>" style="width: 22%;">
<?php } else {?>
<img src="<?php echo base_url()?>reports-assets-new/images/img2.png">
<?php } ?>
<div class="info-wrap-inner">
<p><span>Name </span> : <?php echo $user_details->st_name;?></p>
<p><span>Age </span> : <?php echo $age;?></p>
<p><span>Education </span> : <?php echo $user_details->st_qualification;?></p>
<p><span>Mobile </span> : <?php echo $user_details->st_mobile;?></p>
<p><span>Email </span> : <?php echo $user_details->st_email;?></p>
<p><span>Date of test </span> : <?php $s=$user_details->c_date; $dt = new DateTime($s); $date = $dt->format('d-m-Y'); echo $date; ?></p>
</div>
</div>
</div>
<div class="col-md-7 report-wrapper">
<h1 class="heading">SKILL FINDER TEST REPORT</h1>
<p><?php echo $test_details->description;?></p>
</div>
</div>
</section>
<section class="skills">
<div class="container">
<div class="row">
<div class="col-md-12">
<h1><span>IDENTIFY SKILLS BASED ON YOUR INTERESTS</span></h1>
</div>
</div>
<div class="row">
<?php echo $test_details->description3;?>
</div>
</div>
</section>
</div><!-- pdfdiv close -->
Generally the IDE show these errors in red.
Example with IntelliJ softwares :
Following is my code I am displaying details as 3 columns per row using Bootstrap class row.
I tried like changing div and some condition
<div class="container">
<?php
if($lclResult->rowCount() > 0){
while($row = $lclResult->fetch(PDO::FETCH_ASSOC)) {
# code...
$lclUserName = $row['us_business_name'];
$lclImage1 = $row['us_image1'];
$lclCategory = $row['us_category'];
$lclArea = $row['us_area'];
?>
<div class="row">
<div class="col-sm-4">
<div class="card">
<img class="card-img-top " src="<?php echo $lclImage1 ?>" alt="Card image" style="width:100%; height: 158px;">
<div class="card-body">
<h4 class="card-title"><?php echo $lclUserName?></h4>
<p class="card-text" style="font-size: 25px;"><?php echo $lclCategory?></p>
<hr>
<i class="fa fa-map-marker" style="font-size: 23px;"><span> </span><?php echo $lclArea?></i>
<!-- See Profile -->
</div>
</div>
<?php
}
?>
</div>
<?php
} else {
?>
<div class="container">
<div class="row">
<div class="col-sm-12">
<h1> NO RESULT FOUND...</h1>
</div>
</div>
</div>
<?php
}
?>
</div>
</div>
I want to display 3 columns per row to display data. If anyone knows Please guide me with the above code.
Change your code like this
<div class="container">
<div class="row">
<?php
if($lclResult->rowCount() > 0){
while($row = $lclResult->fetch(PDO::FETCH_ASSOC)) {
# code...
$lclUserName = $row['us_business_name'];
$lclImage1 = $row['us_image1'];
$lclCategory = $row['us_category'];
$lclArea = $row['us_area'];
?>
<div class="col-sm-4">
<div class="card">
<img class="card-img-top " src="<?php echo $lclImage1 ?>" alt="Card image" style="width:100%; height: 158px;">
<div class="card-body">
<h4 class="card-title">
<?php echo $lclUserName?>
</h4>
<p class="card-text" style="font-size: 25px;">
<?php echo $lclCategory?>
</p>
<hr>
<i class="fa fa-map-marker" style="font-size: 23px;">
<span>
</span>
<?php echo $lclArea?>
</i>
<!-- See Profile -->
</div>
</div>
</div>
<?php
}
?>
<?php
} else {
?>
<div class="container">
<div class="row">
<div class="col-sm-12">
<h1> NO RESULT FOUND...
</h1>
</div>
</div>
</div>
<?php
}
?>
</div>
</div>
Have a website in three languages. The porducts select from a mysql database and showed wiht a do-while-loop.
<!-- Shop Page Area Start-->
<div class="shoppage-area">
<div class="container">
<div class="about-desc">
<h2>
<?php echo $page['subtitle']; ?>
</h2>
<?php echo $page['content']; ?>
</div>
<div class="row">
<?php
do {
?>
<!--Product Start-->
<div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
<div class="sngle-product">
<div class="product-thumb">
<img src="<?php echo $product['img']; ?>" alt=""/>
<h2>
<a href="#">
<?php echo $product['name']; ?>
</a>
</h2>
</div>
<h3>
<?php echo $product['desc']; ?>
</h3>
<span><?php echo $product['size']; ?></span> <span class="price"><?php echo $product['price']; ?> LE</span>
<div class="product-overlay">
<ul>
<li>
<div class="product-quantity">
<div class="input-number">
<input type="text" value="1" name="quantity">
</div>
</div>
</li>
<li><a class="orderbtn" href="#" data-uid="<?php echo $product['uniqueid']; ?>">ORDER</a></li>
</ul>
</div>
</div>
</div>
<!-- Product End -->
<?php
} while ($product = $res->fetch_assoc()) ?>
</div>
<!-- end Row -->
</div>
</div>
The problem is that in one language showed correctly and in the other i get a lot spaces between the products. See the image
enter image description here
How i can solve this
Add an additional class flex-row to the product wrapping row element. And try applying the following styles.
.flex-row{
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
}
You can divide your column like this
<div class="shoppage-area">
<div class="container">
<div class="about-desc">
</div>
<div class="row">
<?php $i=1;
do {
?>
<div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
<div class="sngle-product">
<div class="product-thumb">
<img src="<?php echo "test"; ?>" alt=""/>
<h2><?php echo "test"; ?> </h2>
</div>
<h3><?php echo ($i==2)? " testtesttesttesttesttest testtesttesttest test": "test"; ?></h3>
<span><?php echo "test"; ?></span> <span class="price"><?php echo 12321; ?> LE</span>
<div class="product-overlay">
<ul>
<li>
<div class="product-quantity">
<div class="input-number">
<input type="text" value="1" name="quantity">
</div>
</div>
</li>
<li><a class="orderbtn" href="#" data-uid="<?php echo "1231"; ?>">ORDER</a></li>
</ul>
</div>
</div>
</div>
<?php
echo $i%4;
if($i%4== 0 && $i > 1) {
echo '</div><div class="row">';
}
$i++;
} while ($i<=10) ?>
</div>
</div>
</div>
Good Day All,
I am trying to align items in a row of 3. At the top of each row there is a div called "". The purpose of this div is to open a new and after every 3 items the div must be close and another one opened. I have tried the below code to my suprise it is not working. This is very weird as the MOD operand should work. Cna any of you see what I could be doing wrong?
The write picture should look like this
It is out of alignment and the blue colour fills the whole page. I do not know what I am doing wrong:
$currentRow = 1;
echo '<div class="top-box">';
while($Data=mysqli_fetch_array($Result))
{
echo '<div class="col_1_of_3 span_1_of_3">
<a href="Single.php?Query='.$Data[5].'">
<div class="inner_content clearfix">
<div class="product_image">
<img src="images/'.$Data[14].'" height="300" width="320" alt=""/>
</div>
<div class="price">
<div class="cart-left">
<p class="title">'.$Data[11].'</p>
<div class="price1">
<span class="actual">R'.$Data[13].'</span>
</div>
</div>
<div class="cart-right"> </div>
<div class="clear"></div>
</div>
</div>
</a>
</div>';
$currentRow++;
if($currentRow % 3 == 0)
{
echo '</div> ';
echo '<div class="top-box">';
}
}
When I manually repeat the items every 3 items like below, it works perfectly:
<div class="top-box">
<div class="col_1_of_3 span_1_of_3">
<a href="Single.php">
<div class="inner_content clearfix">
<div class="product_image">
<img src="images/1st_Party_Boy.jpg" height="300" width="320" alt=""/>
</div>
<div class="price">
<div class="cart-left">
<p class="title">His First Party</p>
<div class="price1">
<span class="actual">R350.00</span>
</div>
</div>
<div class="cart-right"> </div>
<div class="clear"></div>
</div>
</div>
</a>
</div>
<div class="col_1_of_3 span_1_of_3">
<a href="Single.php">
<div class="inner_content clearfix">
<div class="product_image">
<img src="images/Her_First_Party.jpg" height="300" width="320" alt=""/>
</div>
<div class="sale-box"><span class="on_sale title_shop">New</span></div>
<div class="price">
<div class="cart-left">
<p class="title">Her First of Many </p>
<div class="price1">
<span class="actual">R350.00</span>
</div>
</div>
<div class="cart-right"> </div>
<div class="clear"></div>
</div>
</div>
</a>
</div>
<div class="col_1_of_3 span_1_of_3">
<a href="Single.php">
<div class="inner_content clearfix">
<div class="product_image">
<img src="images/First_one_for_boys_and_girls.jpg" height="300" width="320" alt=""/>
</div>
<div class="price">
<div class="cart-left">
<p class="title">Their First Birthday</p>
<div class="price1">
<span class="actual">R350.00</span>
</div>
</div>
<div class="cart-right"> </div>
<div class="clear"></div>
</div>
</div>
</a>
</div>
<div class="clear"></div>
</div>
Hey change $currentRow to zero
$currentRow = 0;
echo '<div class="top-box">';
while($Data=mysqli_fetch_array($Result))
{
echo '<div class="col_1_of_3 span_1_of_3">
<a href="Single.php?Query='.$Data[5].'">
<div class="inner_content clearfix">
<div class="product_image">
<img src="images/'.$Data[14].'" height="300" width="320" alt=""/>
</div>
<div class="price">
<div class="cart-left">
<p class="title">'.$Data[11].'</p>
<div class="price1">
<span class="actual">R'.$Data[13].'</span>
</div>
</div>
<div class="cart-right"> </div>
<div class="clear"></div>
</div>
</div>
</a>
</div>';
$currentRow++;
if($currentRow % 3 == 0)
{
echo '</div> ';
echo '<div class="top-box">';
}
}