← Desenvolvimento

Dúvida com php / mysql

Lida 982 vezes

Offline

cjseven 
Administrador
Mensagens 1809 Gostos 26
Feedback +3

Troféus totais: 28
Trófeus: (Ver todos)
Super Combination Combination Topic Starter Poll Voter Level 5 Level 4 Level 3 Level 2 Level 1 1000 Posts

Boas!

Tenho um site que apresenta uma lista zebrada de conteúdo puxado de uma base de dados mysql.

O código puxa linha a linha até termina o ciclo.

O meu objectivo é fazer com que o código puxe duas ou três linhas de cada vez (para poder inserir pub no meio dessas linhas)

Já tentei por meio de tentativas e erro mas não estou a conseguir... por isso peço uma dica para resolver o problema.

Aqui está o código:

Código: [Seleccione]
<div class="list">
<?php 
$i 1

if(!empty($_GET['sort']))
{
$orderby=trim($_GET['sort']);
$order=trim($_GET['order']);
$key=trim($_GET['key']);

// create the sort by injection
$posts query_posts($query_string '&orderby='.$orderby.'&meta_key='.$key.'&order='.$order.'');
}

if (have_posts()) : ?>


<?php while (have_posts()) : the_post(); ?>

<?php if ($i == 0) { $alt " class=\"alt\""; } else { $alt " class=\"no\""; } echo "<div" $alt;
if (is_sticky()) { echo " id='sticky' "; } echo ">"
?>


<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">

<?php if ( get_option('main_page_img') != "no" ) { ?>

<span class="image">
<?php $images get_post_meta($post->ID"images"true);
if (empty($images)) {?>

    <div class="main_page_no_img"><img src="<?php bloginfo('template_url'); ?>/images/no-pic.png" alt="No Photo" border="0" /></div></span>
<?php } else { ?>
<div class="main_page_img" style="background: #FFF url(<?php echo get_bloginfo('template_url')."/includes/img_resize.php?width=50&height=50&url=";?><?php
  if ( strstr($images',')) {  
$matches explode(","$images);
$img_single $matches[0];
$img_single explode(trailingslashit(get_option('siteurl')) . "wp-content/uploads/classipress/"$img_single);
echo $img_single[1];
  } else {
$img_single2 $images;
echo $img_single2;
}?>
) center no-repeat"></div></span>
<?php 

} else {
$ii 1;
echo "<span class='cat_image'>";
foreach((get_the_category()) as $category) {
if ($ii == "1") {
$cat_image get_bloginfo('template_url')."/images/category-icons/".get_option("cat$category->cat_ID").".png";
echo "<img src=" $cat_image ">";
$ii++;
}
}
echo "</span>";
?>


<span class="item"><div style="text-decoration:underline; font-weight:bold;"><?php if ( strlen(get_the_title()) > 65 ) { echo substr(get_the_title(), 065)."..."; } else { the_title(); } ?></div>
<?php echo substr(strip_tags($post->post_content), 0190)."...";?></span>
<span class="price"><?php echo get_option('currency'); ?><?php echo get_post_meta($post->ID"price"true); ?></span>
<span class="location"><?php echo get_post_meta($post->ID"location"true); ?></span>
<span class="date"><?php echo classi_time($post->post_date); ?></span>
</a>

<br />



<div class="clear"></div>
</div>



<?php $i++; unset($alt); ?>

<?php endwhile; ?>

Não coloco o código total da página porque acho que não está relacionado.

Obrigado.
Offline

cjseven 
Administrador
Mensagens 1809 Gostos 26
Feedback +3

Troféus totais: 28
Trófeus: (Ver todos)
Super Combination Combination Topic Starter Poll Voter Level 5 Level 4 Level 3 Level 2 Level 1 1000 Posts

já descobri uma solução.

Obrigado.