I am trying to make it so only the 3 with the highest scores show up. How would I make it only echo 3 times with the highest scores?
Right now it goes through and echos every input. It should show up as a top 3 list with best scores, their names, and their picture.
I have tried with the max($ar) but I cant get it to show both image, score and name together.
$n1 = get_option('scoreboard_option_name1');
$n2 = get_option('scoreboard_option_name2');
$n3 = get_option('scoreboard_option_name3');
$n4 = get_option('scoreboard_option_name4');
$n5 = get_option('scoreboard_option_name5');
$n6 = get_option('scoreboard_option_name6');
$n7 = get_option('scoreboard_option_name7');
$n8 = get_option('scoreboard_option_name8');
$n9 = get_option('scoreboard_option_name9');
$n10 = get_option('scoreboard_option_name10');
$n11 = get_option('scoreboard_option_name11');
$n12 = get_option('scoreboard_option_name12');
$n13 = get_option('scoreboard_option_name13');
$n14 = get_option('scoreboard_option_name14');
$n15 = get_option('scoreboard_option_name15');
$n16 = get_option('scoreboard_option_name16');
$n17 = get_option('scoreboard_option_name17');
$n18 = get_option('scoreboard_option_name18');
$n19 = get_option('scoreboard_option_name19');
$n20 = get_option('scoreboard_option_name20');
$s1 = get_option('scoreboard_option_score1');
$s2 = get_option('scoreboard_option_score2');
$s3 = get_option('scoreboard_option_score3');
$s4 = get_option('scoreboard_option_score4');
$s5 = get_option('scoreboard_option_score5');
$s6 = get_option('scoreboard_option_score6');
$s7 = get_option('scoreboard_option_score7');
$s8 = get_option('scoreboard_option_score8');
$s9 = get_option('scoreboard_option_score9');
$s10 = get_option('scoreboard_option_score10');
$s11 = get_option('scoreboard_option_score11');
$s12 = get_option('scoreboard_option_score12');
$s13 = get_option('scoreboard_option_score13');
$s14 = get_option('scoreboard_option_score14');
$s15 = get_option('scoreboard_option_score15');
$s16 = get_option('scoreboard_option_score16');
$s17 = get_option('scoreboard_option_score17');
$s18 = get_option('scoreboard_option_score18');
$s19 = get_option('scoreboard_option_score19');
$s20 = get_option('scoreboard_option_score20');
$p1 = get_option('scoreboard_image1');
$p2 = get_option('scoreboard_image2');
$p3 = get_option('scoreboard_image3');
$p4 = get_option('scoreboard_image4');
$p5 = get_option('scoreboard_image5');
$p6 = get_option('scoreboard_image6');
$p7 = get_option('scoreboard_image7');
$p8 = get_option('scoreboard_image8');
$p9 = get_option('scoreboard_image9');
$p10 = get_option('scoreboard_image10');
$p11 = get_option('scoreboard_image11');
$p12 = get_option('scoreboard_image12');
$p13 = get_option('scoreboard_image13');
$p14 = get_option('scoreboard_image14');
$p15 = get_option('scoreboard_image15');
$p16 = get_option('scoreboard_image16');
$p17 = get_option('scoreboard_image17');
$p18 = get_option('scoreboard_image18');
$p19 = get_option('scoreboard_image19');
$p20 = get_option('scoreboard_image20');
$cp1 = get_option('scoreboard_carimage1');
$cp2 = get_option('scoreboard_carimage2');
$cp3 = get_option('scoreboard_carimage3');
$cp4 = get_option('scoreboard_carimage4');
$cp5 = get_option('scoreboard_carimage5');
$cp6 = get_option('scoreboard_carimage6');
$cp7 = get_option('scoreboard_carimage7');
$cp8 = get_option('scoreboard_carimage8');
$cp9 = get_option('scoreboard_carimage9');
$cp10 = get_option('scoreboard_carimage10');
$cp11 = get_option('scoreboard_carimage11');
$cp12 = get_option('scoreboard_carimage12');
$cp13 = get_option('scoreboard_carimage13');
$cp14 = get_option('scoreboard_carimage14');
$cp15 = get_option('scoreboard_carimage15');
$cp16 = get_option('scoreboard_carimage16');
$cp17 = get_option('scoreboard_carimage17');
$cp18 = get_option('scoreboard_carimage18');
$cp19 = get_option('scoreboard_carimage19');
$cp20 = get_option('scoreboard_carimage20');
$namelist = array($n1, $n2, $n3, $n4, $n5, $n6, $n7, $n8, $n9, $n10, $n11, $n12, $n13, $n14, $n15, $n16, $n17, $n18, $n19, $n20, );
$scorelist = array($s1, $s2, $s3, $s4,$s5, $s6, $s7, $s8, $s9, $s10,$s11,$s12,$s13,$s14,$s15,$s16,$s17,$s18,$s19,$s20 );
$picturelist = array($p1, $p2, $p3, $p4, $p5, $p6, $p7, $p8, $p9, $p10, $p11, $p12, $p13, $p14, $p15, $p16, $p17, $p18, $p19, $p20 );
$carlist = array($cp1, $cp2, $cp3, $cp4, $cp5, $cp6, $cp7, $cp8, $cp9, $cp10, $cp11, $cp12, $cp13, $cp14, $cp15, $cp16, $cp17, $cp18, $cp19, $cp20 );
$carlist = array($cp1, $cp2, $cp3, $cp4, $cp5, $cp6, $cp7, $cp8, $cp9, $cp10, $cp11, $cp12, $cp13, $cp14, $cp15, $cp16, $cp17, $cp18, $cp19, $cp20 );
?>
<div class="row">
<?php
$i = -1;
foreach ($namelist as $name) {
$i++;
echo '
<div class="column" style="float: left; width: 33.33%; padding-top: 35px; padding-bottom: 35px; border-bottom: 2px solid red; height: 493px;">
<div class="et_pb_module et_pb_code et_pb_code_0 et_pb_text_align_center">
<div class="et_pb_code_inner">'.$imgPlaceholder.'</div>
</div> <!-- .et_pb_code -->
<div class="et_pb_module et_pb_code et_pb_code_1 et_pb_text_align_center">
<div class="et_pb_code_inner">
<h2 style="font-size: calc(0.7em + 1vw)">', $namePlaceholder, '</h2>
</div>
</div> <!-- .et_pb_code -->
<div class="et_pb_module et_pb_code et_pb_code_2 et_pb_text_align_center">
<div class="et_pb_code_inner">
<h4> <b>
', $scorelist[$i], ' point
</b>
</h4>
</div>
</div> <!-- .et_pb_code -->
<div class="et_pb_code_inner" style="
text-align: center;
">
<img src="', $carlist[$i] ,'" alt="" class="alignnone size-thumbnail wp-image-30280" width="200">
</div>
</div> <!-- .et_pb_column -->
';
}
?>
</div>
The thing you are looking for here is array sorting. Since I don't know what's the exact key to value pairing of the $scorelist array, I'll assume it's a numeric array with the scores stored as values, to sort this array you need to use arsort function.
<?php
arsort($scorelist);
foreach($scorelist as $key => $score){
echo $score;
}
This code will print you the scores based on their highest values. From there on you can add your HTML and other values by using the $key inside the foreach, that will give you the index number of the element so you can access your other list elements with it.
Okay, the way your data is structured is not ideal. So I've changed that for you so we can manipulate things properly. Bear in mind that I didn't test this so you may have to tweak some things yourself but this is more or less what you need to do.
<?php
// Structure data into an associative array in order to easily access related data
$racers = array();
for ($n=1; $n<21; $n++) {
array_push($racers, array(
get_option("scoreboard_option_score{$n}") => array(
'name' => get_option("scoreboard_option_name{$n}"),
'picture' => get_option("scoreboard_option_image{$n}"),
'car' => get_option("scoreboard_option_carimage{$n}"),
)
));
}
?>
<div class="row">
<?php
// Get top 3 scores
krsort($racers);
$top3 = (array_slice($scorelist, 0, 3));
// Use key in top3 to determine which name, car and picture it relates to
foreach ($top3 as $score => $data) {
?>
<div class="column" style="float: left; width: 33.33%; padding-top: 35px; padding-bottom: 35px; border-bottom: 2px solid red; height: 493px;">
<div class="et_pb_module et_pb_code et_pb_code_0 et_pb_text_align_center">
<div class="et_pb_code_inner">
<!-- Racer Image -->
<img src="<?php echo $data['picture']; ?>" alt="<?php echo $data['name']; ?>">
</div>
</div> <!-- .et_pb_code -->
<div class="et_pb_module et_pb_code et_pb_code_1 et_pb_text_align_center">
<div class="et_pb_code_inner">
<h2 style="font-size: calc(0.7em + 1vw)">
<!-- Racer Name -->
<?php echo $data['name']; ?>
</h2>
</div>
</div> <!-- .et_pb_code -->
<div class="et_pb_module et_pb_code et_pb_code_2 et_pb_text_align_center">
<div class="et_pb_code_inner">
<h4>
<b>
<?php echo "{$score} points" ?>
</b>
</h4>
</div>
</div> <!-- .et_pb_code -->
<div class="et_pb_code_inner" style="text-align: center;">
<img src="<?php echo $data['car']; ?>" alt="" class="alignnone size-thumbnail wp-image-30280" width="200">
</div>
</div> <!-- .et_pb_column -->
<?php
}
?>
</div>
I'm currently trying to build out a multi-endpoint system for WP-JSON between 4 websites, and most of the time it's fine, however sometimes when my page performs the process, it will throw back an error for the Foreach cycle, saying 'Warning: Invalid argument supplied for foreach() in ...'
I've tried alternative methods of merging the arrays before retrieving the body using wp_remote_retrieve_body but there's no such luck. I've looked up various google solutions on multiple-endpoints using php but nothing i've found seems to do an effective job
<?php
function limit_text($text, $limit) {
if (str_word_count($text, 0) > $limit) {
$words = str_word_count($text, 2);
$pos = array_keys($words);
$text = substr($text, 0, $pos[$limit]) . '...';
}
return $text;
}
/* BASE DETAILS FOR SEARCH*/
$b_url = get_site_url(); // Base URL
$posts_merged;
$args = array(
'sslverify' => false
);
if($_GET['search'] or !empty($_GET['search'])){
$filter_query = '?search='.$_GET['search'];
}else{
$filter_query = '';
}
$post_url_collective = array(
$b_url.'/wp-json/wp/v2/posts'.$filter_query, // Main Site
$b_url.'/db/wp-json/wp/v2/posts'.$filter_query, // DB Site
$b_url.'/dc/wp-json/wp/v2/posts'.$filter_query, // DC Site
$b_url.'/fw/wp-json/wp/v2/posts'.$filter_query // FW Site
);
$post_response = wp_remote_get($post_url_collective[0], $args);
$post_response = wp_remote_retrieve_body($post_response);
$post_response = json_decode($post_response);
$post_response_two = wp_remote_get($post_url_collective[1], $args);
$post_response_two = wp_remote_retrieve_body($post_response_two);
$post_response_two = json_decode($post_response_two);
$post_response_three = wp_remote_get($post_url_collective[2], $args);
$post_response_three = wp_remote_retrieve_body($post_response_three);
$post_response_three = json_decode($post_response_three);
$post_response_four = wp_remote_get($post_url_collective[3], $args);
$post_response_four = wp_remote_retrieve_body($post_response_four);
$post_response_four = json_decode($post_response_four);
$posts_merged = array_merge( $post_response, $post_response_two, $post_response_three, $post_response_four );
?>
<div class="container multi-search-wrap">
<div class="row" style="margin-bottom: 0px">
<div class="col sm12 m12 l12">
<form class="multi-search-form" method="GET">
<div class="row" style="margin-bottom: 0px">
<div class="col sm8 m9 l10">
<input type="text" name="search" value="<?php echo ( isset( $_GET['search'] ) ? $_GET['search'] : '' ); ?>" placeholder="Search for..."/>
</div>
<div class="col sm4 m3 l2">
<input type="submit" value="Search" />
</div>
</div>
</form>
</div>
</div>
<div class="row" style="background: #eeeeee;padding: 10px;font-size: 12px;margin:0px 0px 20px 0px">
<div class="col sm12 m12 l12">
We've found <strong><?php echo count($posts_merged);?></strong> results for <?php echo $_GET['search'];?>...
</div>
</div>
<div class="row">
<?php
// Post Loop
foreach($posts_merged as $get_post) {
$image_url = $b_url.'/wp-json/wp/v2/media/'.$get_post->featured_media;
$image_response = wp_remote_get($image_url, $args);
$image_response = json_decode($image_response['body']);
//echo'<pre>';print_r($image_response);echo'</pre>';
echo '<div class="col sm12 m6 l6 multi-search-post">';
echo '<div class="row">';
echo '<div class="col sm12 m3 l4 multi-search-post">';
if(!empty($image_response->media_details->sizes->thumbnail->source_url)){
echo '<img class="img_'.$get_post->id.'" src="'.$image_response->media_details->sizes->thumbnail->source_url.'" width="auto"><br>';
}else{
echo '<img class="img_'.$get_post->id.'" src="'.get_template_directory_uri().'/images/post-placeholder.jpg" width="auto"><br>';
}
echo '</div>';
echo '<div class="col sm12 m9 l8 multi-search-post">';
echo '<a href="'.$get_post->link.'">';
echo '<h3>'.$get_post->title->rendered.'</h3>';
echo '</a>';
echo '<p>'.limit_text($get_post->excerpt->rendered, 30).'</p>';
echo '</div>';
echo '</div>';
echo '</div>';
}
?>
</div>
</div>
I would like to improve the load speed of the queries but the most important part is ridding this occassional Foreach error.
Any help would be greatly appreciated
I am creating a seat reservation system. In my system, the code check number of seats a bus contains then pass it inside a for loop. When a user pick 2 passengers, it means two seats will be booked. How can I validate the checkbox in the for loop depending on the number of passenger(s) selected.
Using the GUI for more explanation.
on the main page, 2 there indicates number of passenger(s) selected.
When you come to the second page where the values are passed to, you can see 2 Adults as the selected number of passengers. When you click on Submit Button it does not validate the checkbox based on the number of passenger(s) selected. And if I should put required in the checkbox it validates the whole checkbox since it is in a loop
$_SESSION['seat_no'] is the number of seat(s) a bus contains. Let assume a user that want to book a seat selected two passengers which means two seats is booked, how can I validate the checkbox based on the number of seat(s) selected?
Here is my code:
<?php
for ($i = 1; $i <= $_SESSION['seat_no']; $i++) {
if(in_array($i,$mseat)){
echo "<div class='checkbox_wrapper_pick'>
<label>".$i."</label>
</div>";
}else{
echo "<div class='checkbox_wrapper'>
<input type='checkbox' value=".$i." name='seat_book[]' />
<label>".$i."</label>
</div>";
}
}
?>
The full source code:
<?php include("header.php"); error_reporting(0); ?>
<?php
if(isset($_POST['submit'])){
$from = $_POST['from'];
$to = $_POST['to'];
$date = $_POST['d_date'];
$nop = $_POST['nop'];
$_SESSION['from'] = $from;
$_SESSION['to'] = $to;
$_SESSION['date'] = $date;
$_SESSION['nop'] = $nop;
$get = mysqli_query($mysqli,"SELECT * FROM routes WHERE present_loc = '$from' and destination = '$to' ");
while($roys = mysqli_fetch_array($get)){
//get bus details
$bno = $roys['bus_no'];
$ploc = $roys['present_loc'];
$des = $roys['destination'];
$time = $roys['dept_time'];
$_SESSION['time'] = $time;
$amt = $roys['amount'];
$_SESSION['amt'] = $amt;
$b = str_replace( ',', '',$_SESSION['amt'] );
if( is_numeric($b) ) {
$a = $b;
}
$bus = mysqli_query($mysqli,"select * from bus where bus_no = '$bno'");
while($bu = mysqli_fetch_array($bus)){
$_SESSION['model'] = $bu['model'];
$_SESSION['seat_no'] = $bu['seat_no'];
$_SESSION['ac'] = $bu['bus_type'];
$_SESSION['excess_luggage'] = $bu['excess_luggage'];
$_SESSION['more_legs'] = $bu['more_legs'];
$_SESSION['id'] = $bu['id'];
}
$coun = mysqli_query($mysqli, "select count(booking_id) as seat, seats from booking where bus_no = '$bno' and seats !='' GROUP by booking_id" );
$mseat = array();
while($e = mysqli_fetch_array($coun)){
$bseat = $e['seat'];
$mseat[] = $e['seats'];
}
//$seatss = array();
$seat_string = implode(",",$mseat);
//get seats
$couns = mysqli_query($mysqli, "select sum(counter) as seat from booking where bus_no = '$bno' and seats !='' GROUP by bus_no" );
$rseats = mysqli_fetch_array($couns);
$lseat = $rseats['seat'];
if($_SESSION['seat_no'] == $lseat){
$tell = " No more seat(s) available.";
}else{
$tell = $_SESSION['seat_no'] - $lseat. " Seat(s) remaining.";
}
}
}
?>
<!--Main layout-->
<main class="mt-5">
<!--Main container-->
<form action="details" method="POST">
<!--Grid row-->
<div class="row">
<div class="col-lg-12 title-header mb-3 mx-auto z-depth-1">
<div class="row">
<div class="col-lg-8">
<?php echo '<h2> '.$_SESSION['from']. ' to '. $_SESSION['to']. '</h2>'; ?><br/>
<b><?php echo $_SESSION['date']; ?> :: <?php if($_SESSION['nop'] < '2') { echo $_SESSION['nop'] . ' Adult'; }
elseif($_SESSION['nop'] > 1) { echo $_SESSION['nop'] . ' Adults'; }
?></b>
</div>
</div>
</div>
<div class="col-lg-12 mbody"> <label style="margin-left: 4%; font-weight:bolder; font-size:20px; color:#000;">Details </label> </div>
<div class="col-lg-12 mbody bg-white ">
<table class="table table_view" style = "width: 100%; margin-left: 4%; margin-right:4%;">
<tbody>
<tr>
<td><b><?php echo $_SESSION['model']; ?></b><br/><?php echo $_SESSION['from']. ' to '. $_SESSION['to']; ?>
<br/><?php if($_SESSION['ac'] == 'AC') { echo '<span class="alert-info ac">'. $_SESSION['ac'] .'</span>'; }
else{ echo '<span class="alert-warning">No AC</pan>'; } ?>
<?php if($_SESSION['more_legs'] == 'Yes') { echo '<span class="alert-info ac">More Leg Room</span>'; }
else{ echo '<span class="alert-warning no">More Leg Not Available</pan>'; } ?>
</td>
<td><b>Departing Time</b><br/><i class="fa fa-clock-o" aria-hidden="true"></i> <?php echo $_SESSION['time']; ?></td>
<td> <img id = "seatimg" src="../images/seatsLayout/av.gif" class="img-responsive"> <?php echo $tell; ?></td>
<td>Adult <b>₦<?php echo $_SESSION['amt']; ?></b></td>
</tr>
</tbody>
</table>
</div>
<div class="col-lg-12">
<div class="col-lg-12 mbody"> <label style="margin-left: 3%; font-weight:bolder; font-size:20px; color:#000;"><img id = "seatimg" src="../images/seatsLayout/av.gif" class="img-responsive"> Select Seat</label> </div>
<div class="row detail">
<!--Grid column-->
<div class="col-lg-7 animation slideUp" >
<div class="well" id="bus_seats_layout" >
<table class="table table-bordered" cellspacing = "1" id="seatstable">
<tr>
<td><img id = "driverimg" src="../images/seatsLayout/steering.png" class="img-responsive" width="25" height="25"></td>
<td colspan="2" rowspan="3">
<?php
for ($i = 1; $i <= $_SESSION['seat_no']; $i++) {
if(in_array($i,$mseat)){
echo "
<div class='checkbox_wrapper_pick'>
<label>".$i."</label>
</div>
";
}else{
echo "
<div class='checkbox_wrapper'>
<input type='checkbox' value=".$i." name='seat_book[]' />
<label>".$i."</label>
</div>
";
}
}
?>
</td>
</tr>
</table>
</div>
</div>
<div class="col-lg-5">
<ul class="bt">
<li><img src="../images/seatsLayout/seat_available.png" class="img-responsive"> Available</li>
<li><img src="../images/seatsLayout/picked.png" class="img-responsive"> Selected</li>
<li><img src="../images/seatsLayout/seat_booked.png" class="img-responsive"> Booked</li>
</ul>
</div>
</div>
<div class="col-lg-12">
<input type="hidden" name="bus_no" value="<?php echo $bno; ?>">
<input type="hidden" name="to" value="<?php echo $to; ?>">
<input type="hidden" name="from" value="<?php echo $from; ?>">
<input type="hidden" name="amt" value="<?php echo $nop*$a; ?>">
<input type="hidden" name="nop" value="<?php echo $nop; ?>">
<div class="form-group">
<div align="right">
<input type="submit" name="submit" class="bme" value="Continue">
</div>
</div>
</div>
</div>
</div>
</form>
</main>
<?php include("footer.php"); ?>
I'm making a site with conrete5. It's the first one I might add. I have made myself a couple of custom blocks. Named News, Teammates and References.
Now News and Teammates are not editable anymore. I will paste the News -blocks sourcecode.
----------- FORM.php ---------------------
<?php defined('C5_EXECUTE') or die(_("Access Denied.")); ?>
<?php
$al = Loader::helper('concrete/asset_library');
echo $al->file('optional', 'fID', t('Valitse kuva'), $bf, $args);
?>
<div class="form-group">
<?php echo $form->label('otsikko', t('Otsikko'));?>
<?php echo $form->text('otsikko', $otsikko);?>
</div>
<div class="form-group">
<?php echo $form->label('teksti', t('Teksti'));?>
<?php echo $form->text('teksti', $teksti); ?>
</div>
<div class="form-group">
<?php echo $form->label('korkeus', t('Korkeus'));?>
<?php echo $form->select('korkeus', array("108px"=>t("Pieni"),"299px"=>t("Iso")), $korkeus); ?>
</div>
<div class="form-group">
<?php echo $form->label('koko', t('Leveys'));?>
<?php echo $form->select('koko', array("col-md-3"=>t("Pieni"),"col-md-6"=>t("Iso")), $koko); ?>
</div>
<div class="form-group">
<?php echo $form->label('link', t('Linkki'));?>
<?php echo $form->text('link', $link); ?>
</div>
<div class="form-group">
<?php $psh = Loader::helper('form/page_selector');
echo $psh->selectPage('targetCID', $targetCID); ?>
</div>
----------- view.php ---------------------
<?php
defined('C5_EXECUTE') or die(_("Access Denied."));
$c = Page::getCurrentPage();
if($size=="col-md-3"){
$class='col-md-3';
$tag = $class;
}else{
$class="col-md-6";
$tag= $class;
}
if ($c->isEditMode()){
$class="editmode";
$editingStyle="padding: 15px; background: #ccc; color: #444; border: 1px solid #999;";
}
else {
$editingStyle = "";
}
$random = rand();
if($korkeus == "299px"){
$padding = '4px';
}else {
$padding = '5px';
}
$p = Page::getByID($targetCID);
$a = new GlobalArea('Header Navigation');
$blocks = $a->getAreaBlocksArray($c);
foreach ($blocks as $block){
if ($block->getBlockTypeHandle()=="autonav"){
$block->setCustomTemplate('cdrop.php'); // it's templates/cdrop.php -check the select option values when you set custom template manually at edit mode. I think you will need just "my_template"
$bv = new BlockView($block);
$bv->render('view');
}
}
?>
<?php $p = Page::getByID($targetCID); ?>
<a href="index.php">
<div class="pull-left <?= $koko;?>" style="padding:<?= $padding ?>;<?php echo $editingStyle;?>">
<div class="col-lg-12 alapalkki box" style="z-index:2;position:relative;">
<div class="image-big" style="background-color:transparent;text-align:center;position:relative;z-index:1;">
<!-- FiGuRe this shit out......... !-->
<?php
if($fID != 0){
$file = File::getByID($fID);
$filePath = $file->getVersion()->getRelativePath();
}
?>
<?php echo '<img src="' . $filePath . '" style="max-height:' . $korkeus . ';width:100%;"/>'; ?>
</div>
<div class="col-lg-12 " style="position:relative;z-index:255;padding:2px 0 0 15px;">
<div class="htitle">
<h4 style="color:white;"><b><?php echo $otsikko; ?></b></h4>
<p style="color:white;"><?php echo $teksti; ?></p>
</div>
</div>
</div>
</div>
</a>
Why is this not being an editable block? Why doesn't the concrete5 even recognize its existence when it is on the page? It just says at the area that it's empty.
$p = Page::getByID($targetCID);
$a = new GlobalArea('Header Navigation');
$blocks = $a->getAreaBlocksArray($c);
foreach ($blocks as $block){
if ($block->getBlockTypeHandle()=="autonav"){
$block->setCustomTemplate('cdrop.php'); // it's templates/cdrop.php -check the select option values when you set custom template manually at edit mode. I think you will need just "my_template"
$bv = new BlockView($block);
$bv->render('view');
}
}
?>
There's the problem. No idea what so ever what that is doing there..... Removed it. Worked like a charm.
-Kevin
I'm retrieving data out of a database using PHP's PDO extension. I never had a problem with this and it always shows up in all browsers. BUT when I tested the website on a friends laptop, the foreach loop works but the content is not displayed. The content is present in the source code.
this is how I set up the code that should be displayed:
<?php
foreach($advertentiesManager->recenteAdvertenties() as $advertentie) {
$verkoperData = $usersManager->userData($advertentie->verkoper);
?>
<div class="col-md-4" style="margin:10px 0;">
<div class="advertentie">
<div class="overlay"></div>
<div class="img" style="background:url('images/categorie/<?php echo $advertentie->categorie; ?>.jpg') no-repeat center center;background-size:cover;"></div>
<div class="picture" style="background:url('<?php echo str_replace("../", "", $verkoperData->foto); ?>') no-repeat center center;background-size:cover;"></div>
<div class="prijs"><p class="h2"> <?php echo $advertentie->verkoopprijs; ?></p></div>
<div style="padding: 10px;padding-left:80px;margin-top:-40px;">
<a href="<?php echo $advertentie->type.'/'.strtolower(str_replace(" ", "-", $advertentie->titel)).'-'.$advertentie->id; ?>">
<?php echo $advertentie->titel; ?>
</a>
<br>
<p style="color:#777;font-size:.9em;">
<?php
$beschrijving = strip_tags($advertentie->omschrijving);
$max_length = 100;
if (strlen($beschrijving) > $max_length) {
$offset = ($max_length - 3) - strlen($beschrijving);
$beschrijving = substr($beschrijving, 0, strrpos($beschrijving, ' ', $offset)) . '... Meer';
} else {
$beschrijving = $advertentie->omschrijving;
}
echo $beschrijving;
?>
</p>
</div>
</div>
</div>
<?php
}
?>
You can view a live example at http://www.coupontrade.nl/ the content should be displayed under "Recente advertenties" and above the twitter part.