Okay, jeg ved virkelig ikke hvilken overskrift der vil passe bedst.. Anyway
Jeg har dette script jeg køre, hver gang nu de scroller. Men jeg vil høre om jeg ikke kan sætte title til substr() inden den henter fra databasen.. Altså, så de 20 indlæg der kommer frem ikke skal køre samme subst, men kun een gang?
Håber I forstår, her er koden!
- $offset = is_numeric($_POST['offset']) ? $_POST['offset'] : die();
- $postnumbers = is_numeric($_POST['number']) ? $_POST['number'] : die();
-
-
- if ($stmt = $mysqli->prepare("SELECT id, domain, title, text, date FROM ib_posts ORDER BY id DESC LIMIT ".$postnumbers." OFFSET ".$offset."")){
- $stmt->execute();
- $stmt->store_result();
- $stmt->bind_result($id, $domain, $title, $text, $date);
-
- while($stmt->fetch()){
-
- preg_match('@<img.+src="(.*)".*>@Uims', $text, $matches);
- $image = $matches[1];
- $text = strip_tags($text);
- $text = substr_replace($text, "", -1);
- $text = substr($text, 0, 100);
- $text = str_replace("'", "", $text);
- $title = str_replace("'", "", $title);
-
- //if(empty($image)){ $image = 'http://centroclinico-algharb.com/imagens_prv/user.jpg'; }
-
- ?>
- <script>
- makeboxes = function() {
- var boxes = new Array;
-
-
- var randTxt = [
- '<?php if(!empty($image)){ ?><div style="width:350px" class="col one_quarter"><article class="boxed_post"><a href="http://<?php echo $domain; ?>.iblogging.dk" class="boxed_img" class="thumb" data-height="150px"><img src="<?php echo $image; ?>" class="img-responsive" alt="" /><div class="img_overlay"></div></a><div class="boxed_post_wrap"><header><img style="max-width:75px;max-height:75px;" src="<?php echo profile_picture($domain); ?>" alt="" class="avatar"/><h5><a href="blogpost-right-sidebar.html"><?php echo $title; ?></a></h5><p><?php echo $text; ?>..</p></header><ul class="meta"><li style="width:150px;" class="date"><i class="fa fa-clock-o"></i><span><?php echo $date; ?></span></li><li><a href="#"><i class="fa fa-comments"></i><span>0</span></a></li></ul></div></article></div><?php }else{ ?><div style="width:350px" class="col one_quarter"><article class="boxed_post"><div class="boxed_post_wrap"><header><img style="max-width:75px;" src="<?php echo profile_picture($domain); ?>" class="avatar"/><h5><a href="blogpost-right-sidebar.html"><?php echo $title; ?></a></h5><p><?php echo $text; ?>..</p></header><ul class="meta"><li class="date"><i class="fa fa-clock-o"></i><span>30 Aug</span></li><li><a href="#"><i class="fa fa-comments"></i><span>22</span></a></li><li><a href="#"><i class="fa fa-thumbs-up"></i><span>16</span></a></li></ul></div></article></div><?php } ?>'];
-
- num = Math.floor(Math.random()*randTxt.length)
- div = $('<div style="color:#000;"></div>').addClass('item pin');
-
- p = "<p>"+randTxt[num]+"</p>";
-
- div.append(p);
- boxes.push(div);
- return boxes;
- }
- $("#example3").gridalicious('append', makeboxes());
- </script>
-
- <?php
-
- }
- }
- ?>