I'm working on one webpage project and using php to show information of computers. I stored the urls of images in one relation and could successfully retrieve them out with php. But they cannot be shown in the webpage. Here's my code:
<?php
require_once('db_setup_hetty.php');
$sql = "USE hzhu24;";
if ($conn->query($sql) === TRUE){
//echo "using Database hzhu24"
}else{
echo "Error using database:" . $conn->error;
}
$C1 = $_POST["C1"];
$C2 = $_POST["C2"];
$query = "SELECT * FROM Items where Category1 Like '%$C1%' and Category2 Like '%$C2%';";
$result = $conn->query($query);
if($result->num_rows > 0){
?>
<?php
while($row = $result->fetch_assoc()){
$url = $row['Pic_url'];
?>
<div class="col-sm-4">
<div class="thumbnail">
<!--span class="e-label"><div>Sale</div></span-->
<span class="service-link text-center">
<img src= $url>
<div class="list-inline">
<i class="fa fa-eye"></i>
<i class="fa fa-link"></i>
</div>
</span>
<div class="caption">
<div class="category"> <?php echo $C2; ?>
<div class="pull-right">
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star-o"></i>
</div>
</div>
<h3><?php echo $row['Item_name']; ?></h3>
<h4><?php echo $row['Brand']; ?></h4>
<!--strong>$899.00</strong-->
<div>Details</div>
</div>
</div>
</div>
<?php
}
}
else {
echo "Item not found";
}
echo "</table>"
?>
And the webpage looks like:
If your php version >= 5.4, you can just use short echo tag like this:
<?php
require_once('db_setup_hetty.php');
$sql = "USE hzhu24;";
if ($conn->query($sql) === TRUE){
//echo "using Database hzhu24"
}else{
echo "Error using database:" . $conn->error;
}
$C1 = $_POST["C1"];
$C2 = $_POST["C2"];
$query = "SELECT * FROM Items where Category1 Like '%$C1%' and Category2 Like '%$C2%';";
$result = $conn->query($query);
if($result->num_rows > 0){
?>
<?php
while($row = $result->fetch_assoc()){
$url = $row['Pic_url'];
?>
<div class="col-sm-4">
<div class="thumbnail">
<!--span class="e-label"><div>Sale</div></span-->
<span class="service-link text-center">
<img src=<?=$url;?>>
<div class="list-inline">
<i class="fa fa-eye"></i>
<i class="fa fa-link"></i>
</div>
</span>
<div class="caption">
<div class="category">
<?=$C2;?>
<div class="pull-right">
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star-o"></i>
</div>
</div>
<h3><?=$row['Item_name'];?></h3>
<h4><?=$row['Brand'];?></h4>
<!--strong>$899.00</strong-->
<div>Details</div>
</div>
</div>
</div>
<?php
}
}
else {
echo "Item not found";
}
echo "</table>"
Related
Hi. Everything is working perfectly until I clicked the submit button.
This is what it looks like before clicking the submit button. But after clicking it, this is what it will look like. After clicking it, all the information became undefined. Can someone please help me.
I dont know what went wrong. Here is my code.
<?php
session_start();
if(!isset($_SESSION["user"]))
{
header("location:index.php");
}
ob_start();
include ('db.php');
$pid = $_GET['pid'];
$sql ="select * from reservation where reservationno = '$pid' ";
$re = mysqli_query($con,$sql);
while($row=mysqli_fetch_array($re))
{
$clientid = $row['clientid'];
$name = $row['name'];
$reservationno = $row['reservationno'];
$invoiceno = $row['invoiceno'];
$reservationdate = $row['reservationdate'];
$totalamount = $row['totalamount'];
$netamount = $row['netamount'];
$cin = $row['reservefrom'];
$cout = $row['reserveto'];
}
$asql ="select * from reservationdetails where reservationno = '$pid' ";
$are = mysqli_query($con,$asql);
while($row=mysqli_fetch_array($are))
{
$cout2 = $row['checkout2'];
$cout3 = $row['checkout3'];
$days = $row['days'];
$days2 = $row['days2'];
$days3 = $row['days3'];
$roomid = $row['roomid'];
$roomid2 = $row['roomid2'];
$roomid3 = $row['roomid3'];
$qty = $row['qty'];
$qty2 = $row['qty2'];
$qty3 = $row['qty3'];
}
?>
<div id="wrapper">
<nav class="navbar navbar-default top-navbar" role="navigation">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".sidebar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="home.php"><?php echo $_SESSION["user"]; ?> </a>
</div>
<ul class="nav navbar-top-links navbar-right">
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#" aria-expanded="false">
<i class="fa fa-user fa-fw"></i> <i class="fa fa-caret-down"></i>
</a>
<ul class="dropdown-menu dropdown-user">
<li><i class="fa fa-user fa-fw"></i> User Profile
</li>
<li><i class="fa fa-gear fa-fw"> </i> Settings
</li>
<li class="divider"></li>
<li><i class="fa fa-sign-out fa-fw"></i> Logout
</li>
</ul>
<!-- /.dropdown-user -->
</li>
<!-- /.dropdown -->
</ul>
</nav>
<!--/. NAV TOP -->
<nav class="navbar-default navbar-side" role="navigation">
<div class="sidebar-collapse">
<ul class="nav" id="main-menu">
<li>
<i class="fa fa-dashboard"></i> Status
</li>
<li>
<i class="fa fa-desktop"></i> News Letters
</li>
<li>
<i class="fa fa-bar-chart-o"></i>Room Booking
</li>
<li>
<a class="active-menu" href="Payment.php"><i class="fa fa-qrcode"></i> Payment</a>
</li>
<li>
<i class="fa fa-qrcode"></i> Reports
</li>
<li>
</i> Logout
</li>
</div>
</nav>
<!-- /. NAV SIDE -->
<div id="page-wrapper" >
<div id="page-inner">
<div class="row">
<div class="col-md-12">
<h3 class="page-header">
Update Payment
</h3>
</div>
</div>
<!-- /. ROW -->`
<?php
include('db.php');
$mail = "SELECT * FROM `contact`";
$rew = mysqli_query($con,$mail);
?>
<div class="row">
<div class="col-md-12">
<div class="jumbotron">
<div class="panel-body">
<form>
<?php echo $clientid; ?><br>
<?php echo $name; ?><br>
Invoice no: <?php echo $invoiceno; ?><br>
Total Amount: ₱<?php echo $totalamount; ?><br>
Remaining Balance:
<br><br><br>
<h5>Payment:               <h5>
<input type="text" name="updatetextbox" /><br><br>
<h5>Confirm Payment:</h5>
<input type="text" name="updatetextbox1" />
<br>
<center><input type="submit" class="btn btn-primary" />
<?php
if(isset($_POST['submit'])){
$code1=$_POST['updatetextbox1'];
$code=$_POST['updatetextbox'];
if($code1!="$code"){
//$msg="Invalid code";
echo "<script type='text/javascript'> alert('Error')</script>";
}
else
$curdate=date("Y/m/d");
$paymentmode = "Cash";
$amountpaid_cash = 1.00;
$paymentdetails = "INSERT INTO `payments` (`clientid`, `name`, `reservationno`, `paymentmode`, `creditcardno`, `bankname`, `amountpaid_cc`, `amountpaid_cash`, `invoiceno`, `datepaid`) VALUES ('$clientid', '$name', '$reservationno', '$paymentmode', 'NULL', 'NULL', 'NULL', '$amountpaid_cash', '$invoiceno', '$curdate')";
if (mysqli_query($con,$paymentdetails))
{
echo "<script type='text/javascript'> alert('Your Booking application has been sent')</script>";
}
else
{
echo "<script type='text/javascript'> alert('Error adding user in database')</script>";
}
}
?>
</form>
</div>
</div>
</div>
<?php
$sql = "SELECT * FROM `contact`";
$re = mysqli_query($con,$sql);
?>
<!-- /. ROW -->
</div>
</div>
</div>
<!-- /. PAGE INNER -->
</div>
The problem is that you don't pass any of that information to the page after you submit it. Your first example shows pid as an HTTP get variable and that's what you use to define everything else. In your second example (after submit), there is no pid variable. Your code has no way to get the information unless you pass it along with the submit request or you include pid again, so that it can do the same lookup.
for those who came too late here is the answer to this question
you just need to put the insertion statement inside the :
This image will explain the solution
this happened because of the scope of the variables can't be reached outside the if statement block.
I don't understand why, the error says :
Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\twitter\core\ajax\popuptweets.php on line 134 , and I don't see any error or maybe I'm blind !!
popuptweets.php code
<?php
include '../init.php';
if (isset($_POST['showpopup']) && !empty($_POST['showpopup'])) {
$tweetID = $_POST['showpopup'];
$user_id = $_SESSION['user_id'];
$tweet = $getFromT->getPopupTweet($tweetID);
$user = $getFromU->userData($user_id);
$likes = $getFromT->likes($user_id, $tweetID);
$retweet = $getFromT->checkRetweet($tweetID, $user_id);
$comments = $getFromT->comments($tweetID);
?>
<div class="tweet-show-popup-wrap">
<input type="checkbox" id="tweet-show-popup-wrap">
<div class="wrap4">
<label for="tweet-show-popup-wrap">
<div class="tweet-show-popup-box-cut">
<i class="fa fa-times" aria-hidden="true"></i>
</div>
</label>
<div class="tweet-show-popup-box">
<div class="tweet-show-popup-inner">
<div class="tweet-show-popup-head">
<div class="tweet-show-popup-head-left">
<div class="tweet-show-popup-img">
<img src="<?php echo BASE_URL.$tweet->profileImage;?>"/>
</div>
<div class="tweet-show-popup-name">
<div class="t-s-p-n">
<a href="<?php echo BASE_URL.$tweet->username;?>">
<?php echo $tweet->screenName;?>
</a>
</div>
<div class="t-s-p-n-b">
<a href="<?php echo BASE_URL.$tweet->username;?>">
#<?php echo $tweet->username;?>
</a>
</div>
</div>
</div>
<div class="tweet-show-popup-head-right">
<button class="f-btn"><i class="fa fa-user-plus"></i> Follow </button>
</div>
</div>
<div class="tweet-show-popup-tweet-wrap">
<div class="tweet-show-popup-tweet">
<?php echo $getFromT->getTweetLinks($tweet->status);?>
</div>
<div class="tweet-show-popup-tweet-ifram">
<?php if(!empty($tweet->tweetImage)){?>
<img src="<?php echo BASE_URL.$tweet->tweetImage;?>"/>
<?php }?>
</div>
</div>
<div class="tweet-show-popup-footer-wrap">
<div class="tweet-show-popup-retweet-like">
<div class="tweet-show-popup-retweet-left">
<div class="tweet-retweet-count-wrap">
<div class="tweet-retweet-count-head">
RETWEET
</div>
<div class="tweet-retweet-count-body">
<?php echo $tweet->retweetCount;?>
</div>
</div>
<div class="tweet-like-count-wrap">
<div class="tweet-like-count-head">
LIKES
</div>
<div class="tweet-like-count-body">
<?php echo $tweet->likesCount;?>
</div>
</div>
</div>
<div class="tweet-show-popup-retweet-right">
</div>
</div>
<div class="tweet-show-popup-time">
<span><?php echo $tweet->postedOn;?></span>
</div>
<div class="tweet-show-popup-footer-menu">
<ul>
<?php if($getFromU->loggedIn() === true){
echo '<li><i class="fa fa-share" aria-hidden="true"></i></a></button></li>
<li>'.(($tweet->tweetID === $retweet['retweetID']) ? '<button class="retweeted" data-tweet="'.$tweet->tweetID.'" data-user="'.$tweet->tweetBy.'"><a href="#"><i class="fa fa-retweet" aria-hidden="true"></i><span class="retweetsCount">'.$tweet->retweetCount.'</span></button>' : '<button class="retweet" data-tweet="'.$tweet->tweetID.'" data-user="'.$tweet->tweetBy.'"><a href="#"><i class="fa fa-retweet" aria-hidden="true"></i><span class="retweetsCount">'.(($tweet->retweetCount > 0) ? $tweet->retweetCount : '').'</span></button>').'</li>
<li>'.(($likes['likeOn'] === $tweet->tweetID) ? '<button class="unlike-btn" data-tweet="'.$tweet->tweetID.'" data-user="'.$tweet->tweetBy.'"><i class="fa fa-heart-o" aria-hidden="true"></i><span class="likesCounter">'.$tweet->likesCount.'</span></button>' : '<button class="like-btn" data-tweet="'.$tweet->tweetID.'" data-user="'.$tweet->tweetBy.'"><i class="fa fa-heart" aria-hidden="true"></i><span class="likesCounter">'.(($tweet->likesCount > 0) ? $tweet->likesCount : '').'</span></button>').'</li>
<li>
<i class="fa fa-ellipsis-h" aria-hidden="true"></i>
<ul>
<li><label class="deleteTweet">Delete Tweet</label></li>
</ul>
</li>';
}else{
?>
<li><button type="buttton"><i class="fa fa-share" aria-hidden="true"></i></button></li>
<li><button type="button"><i class="fa fa-retweet" aria-hidden="true"></i><span class="retweetsCount">RETWEET-COUNT</span></button></li>
<li><button type="button"><i class="fa fa-heart" aria-hidden="true"></i><span class="likesCount">LIKES-COUNT</span></button></button></li>
<?php }?>
</ul>
</div>
</div>
</div><!--tweet-show-popup-inner end-->
<?php if($getFromU->loggedIn() === true){?>
<div class="tweet-show-popup-footer-input-wrap">
<div class="tweet-show-popup-footer-input-inner">
<div class="tweet-show-popup-footer-input-left">
<img src="<?php echo BASE_URL.$user->profileImage?>"/>
</div>
<div class="tweet-show-popup-footer-input-right">
<input id="commentField" type="text" name="comment" placeholder="Reply to #<?php echo $tweet->username;?>">
</div>
</div>
<div class="tweet-footer">
<div class="t-fo-left">
<ul>
<li>
<label for="t-show-file"><i class="fa fa-camera" aria-hidden="true"></i></label>
<input type="file" id="t-show-file">
</li>
<li class="error-li">
</li>
</ul>
</div>
<div class="t-fo-right">
<span id="count">140</span>
<input type="submit" id="postComment">
</div>
</div>
</div><!--tweet-show-popup-footer-input-wrap end-->
<?php }?>
<div class="tweet-show-popup-comment-wrap">
<div id="comments">
<?php
foreach ($comments as $comment) {
echo '<div class="tweet-show-popup-comment-box">
<div class="tweet-show-popup-comment-inner">
<div class="tweet-show-popup-comment-head">
<div class="tweet-show-popup-comment-head-left">
<div class="tweet-show-popup-comment-img">
<img src="'.BASE_URL.$comment->profileImage.'">
</div>
</div>
<div class="tweet-show-popup-comment-head-right">
<div class="tweet-show-popup-comment-name-box">
<div class="tweet-show-popup-comment-name-box-name">
'.$comment->screenName.'
</div>
<div class="tweet-show-popup-comment-name-box-tname">
#'.$comment->username.' - '.$comment->commentAt.'
</div>
</div>
<div class="tweet-show-popup-comment-right-tweet">
<p>#'.$tweet->username.' '.$comment->comment.'</p>
</div>
<div class="tweet-show-popup-footer-menu">
<ul>
<li><button><i class="fa fa-share" aria-hidden="true"></i></button></li>
<li><i class="fa fa-heart-o" aria-hidden="true"></i></li>
<li>
<i class="fa fa-ellipsis-h" aria-hidden="true"></i>
<ul>
<li><label class="deleteTweet">Delete Tweet</label></li>
</ul>
</li>
</ul>
</div>
</div>
</div>
</div>
<!--TWEET SHOW POPUP COMMENT inner END-->
</div>
';
}
?>
</div>
</div>
<!--tweet-show-popup-box ends-->
</div>
</div>
<?php
}
?>
and the error on foreach that's means on this code
foreach ($comments as $comment) {
echo '<div class="tweet-show-popup-comment-box">
<div class="tweet-show-popup-comment-inner">
<div class="tweet-show-popup-comment-head">
<div class="tweet-show-popup-comment-head-left">
<div class="tweet-show-popup-comment-img">
<img src="'.BASE_URL.$comment->profileImage.'">
</div>
</div>
<div class="tweet-show-popup-comment-head-right">
<div class="tweet-show-popup-comment-name-box">
<div class="tweet-show-popup-comment-name-box-name">
'.$comment->screenName.'
</div>
<div class="tweet-show-popup-comment-name-box-tname">
#'.$comment->username.' - '.$comment->commentAt.'
</div>
</div>
<div class="tweet-show-popup-comment-right-tweet">
<p>#'.$tweet->username.' '.$comment->comment.'</p>
</div>
<div class="tweet-show-popup-footer-menu">
<ul>
<li><button><i class="fa fa-share" aria-hidden="true"></i></button></li>
<li><i class="fa fa-heart-o" aria-hidden="true"></i></li>
<li>
<i class="fa fa-ellipsis-h" aria-hidden="true"></i>
<ul>
<li><label class="deleteTweet">Delete Tweet</label></li>
</ul>
</li>
</ul>
</div>
</div>
</div>
</div>
<!--TWEET SHOW POPUP COMMENT inner END-->
</div>
';
}
where is the error here ?
Arguments for foreach must be an array, you need to var_dump($comments) to see whether it's an array or not. In your case, returning result may be null so it returns warning for foreach. To ensure the foreach working, you may use this:
foreach ((array)$comments as $comment) {
}
I compared your code with mine and found a difference in this line: Do not worry, the error is there.
<li>
'.(($tweet->tweetID ===$retweet['retweetID']) ?
'<button class="retweeted" data-tweet="'.$tweet->tweetID.'" data-user="'.$tweet->tweetBy.'"><a href="#"><i class="fa fa-retweet" aria-hidden="true"></i><span class="retweetsCount">'.$tweet->retweetCount.'</span></button>'
:
'<button class="retweet" data-tweet="'.$tweet->tweetID.'" data-user="'.$tweet->tweetBy.'"><a href="#"><i class="fa fa-retweet" aria-hidden="true"></i><span class="retweetsCount">'.(($tweet->retweetCount > 0) ? $tweet->retweetCount : '') .'</span></button>' ).'<button class="retweet" data-tweet="'.$tweet->tweetID.'" data-user="'.$tweet->tweetBy.'"><a href="#"><i class="fa fa-retweet" aria-hidden="true"></i><span class="retweetsCount"></span></button>
</li>
how can i retrieve specific product details from this page to another page when i click the link?
This is my code for displaying all products in database:
<div class="features_items"><!--features_items-->
<h2 class="title text-center">Features Items</h2>
<?php
$product_array = $db_handle->runQuery("SELECT * FROM tblforface ORDER BY prodid ASC");
if (!empty($product_array)) {
foreach($product_array as $key=>$value){
?>
<div class="col-sm-4">
<div class="product-image-wrapper">
<div class="single-products">
<div class="productinfo text-center">
<img src="images/shop/product12.jpg" alt="" />
<h2><?php echo "₱".$product_array[$key]["prodprice"]; ?></h2>
<p><?php echo $product_array[$key]["prodname"]; ?></p>
<i class="fa fa-shopping-cart"></i>Add to cart
</div>
<div class="product-overlay">
<div class="overlay-content">
<h2><?php echo "₱".$product_array[$key]["prodprice"]; ?></h2>
<p><?php echo $product_array[$key]["prodname"]; ?></p>
<i class="fa fa-shopping-cart"></i>Add to cart
</div>
</div>
</div>
<div class="choose">
<ul class="nav nav-pills nav-justified">
<li><i class="fa fa-plus-square"></i>Add to wishlist</li>
<li><i class="fa fa-plus-square"></i>Add to compare</li>
</ul>
</div>
</div>
</div>
You can add the id into a query string, like http://blah.com/product.php?id=123
<a href="../homescreen/product/product.php?id=<?= $product_array[$key]["id"]; ?>" class="btn btn-default add-to-cart">
<i class="fa fa-shopping-cart"></i>Add to cart
</a>
And in your other page,
$id = filter_input(INPUT_GET, 'id', FILTER_SANITIZE_NUMBER_INT);
We do that instead of the dangerous $id = $_GET['id'];. Check the docs for filter_input here http://php.net/manual/en/function.filter-input.php
I am facing a problem and I would like your help!
I have built this:
$stmt_select = $conn->prepare("SELECT * FROM `stores` WHERE `user_id`=$id;");
$stmt_select->execute();
while ($row_select = $stmt_select->fetch(PDO::FETCH_ASSOC)) {
echo '<ul class="dropdown-menu dropdown-alerts">
<li>
<a href="#">
<div>
<i class="fa fa-home"></i> <strong>'. $row_select['area_store'] .'</strong>
<span class="pull-right text-muted small"><i>'. $row_select['name_store'] .'</i></span>
</div>
</a>
</li>
</ul>';
};
I have two rows into the table but echo displays only one result.Any ideas?
try this code:
$stmt_select = $conn->prepare("SELECT * FROM `stores` WHERE `user_id`=$id;");
$stmt_select->execute();
$res = $stmt_select->get_result();
while ($row_select = $res->fetch_assoc()) {
echo '<ul class="dropdown-menu dropdown-alerts">
<li>
<a href="#">
<div>
<i class="fa fa-home"></i> <strong>'. $row_select['area_store'] .'</strong>
<span class="pull-right text-muted small"><i>'. $row_select['name_store'] .'</i></span>
</div>
</a>
</li>
</ul>';
};
You could fetchAll the data and than do a foreach loop like so
$stmt_select = $conn->prepare("SELECT * FROM `stores` WHERE `user_id`=$id;");
$stmt_select->execute();
$stmt_select = $stmt_select->fetchAll(PDO::FETCH_ASSOC);
foreach ($stmt_select as $row) {
echo '<ul class="dropdown-menu dropdown-alerts">
<li>
<a href="#">
<div>
<i class="fa fa-home"></i> <strong>'. $row['area_store'] .'</strong>
<span class="pull-right text-muted small"><i>'. $row['name_store'] .'</i></span>
</div>
</a>
</li>
</ul>';
}
also i would suggest you to escape your variables before entering the sql query.
$stmt_select = $conn->prepare("SELECT * FROM `stores` WHERE `user_id`= :id");
$stmt_select->execute(["id" => $id]);
$stmt_select = $stmt_select->fetchAll(PDO::FETCH_ASSOC);
Try this it will help solve ur probem
$stmt =$conn->prepare("SELECT * FROM stores where user_id=:user_id")
$stmt->bindValue(":user_id", $id);
$stmt->execute();
$results=$stmt->fetchall(PDO::FETCH_ASSOC);
if(count($results) > 0 ){
foreach ($row as $results) {
echo "<ul class=\"dropdown-menu dropdown-alerts\">
<li>
<a href=\"#\">
<div>
<i class=\"fa fa-home\"></i> <strong>".$row['area_store'] ."</strong>
<span class=\"pull-right text-muted small\"><i>".$row['name_store'] ."</i></span>
</div>
</a>
</li>
</ul>";
}
}elseif (count($results) <= 0) {
echo "no records found";
}
if you found this helpful please mark the answer :)
I want to shorten a string when it's longer than a certain length for example 20.
But when I add the if statement to my echoed html it outputs the result outside of the echoed html. Any idea why this happens?
My code:
foreach($contentcr as $content)
{
$contentje .= '<li class="job_listing">
<a href="http://www.website.nl/_extern/website/content.php?alias='.$content['alias'].'">
<div class="location job_img">
<img src="images/samples/person1.jpg" alt="" class="company_logo">
</div>
<div class="location boldfont">
'.$content['title'].'
</div>
<div class="location">
'.$content['fulltext'].'';
if (strlen($content['fulltext']) >= 20){
echo 'blala';
}
$contentje .='</div>
<div class="rating location">
<div class="rating-stars">
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
</div>
</div>
<div class="location">
'.$content['metakey'].'
</div>
<div class="location">
<button type="submit" class="btn btn-primary buttonblock" onClick="location.href="http://www.website.nl/_extern/website/content.php?page="'.$content['alias'].'">Nu huren</button>
</div>
</a>
</li>'; // Here
}
This is a table like structure, but the output of the if statement is echoed outside the html markup.
You are echoing the string inside if statement rather than appending that to your $contentje variable. See if statement below:
foreach($contentcr as $content)
{
$contentje .= '<li class="job_listing">
<a href="http://www.website.nl/_extern/website/content.php?alias='.$content['alias'].'">
<div class="location job_img">
<img src="images/samples/person1.jpg" alt="" class="company_logo">
</div>
<div class="location boldfont">
'.$content['title'].'
</div>
<div class="location">
'.$content['fulltext'].'';
if (strlen($content['fulltext']) >= 20){
$contentje .= 'blala';
}
$contentje .='</div>
<div class="rating location">
<div class="rating-stars">
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
</div>
</div>
<div class="location"> '.$content['metakey'].'</div>
<div class="location">
<button type="submit" class="btn btn-primary buttonblock" onClick="location.href="http://www.website.nl/_extern/website/content.php?page="'.$content['alias'].'">Nu huren</button>
</div>
</a></li>'; // Here
}