tags:

views:

30

answers:

1

Could anyone help with this please?

I am pulling the results in below from the cms_page_part table. I know for a fact there should be two rows. One where "name" is equal to "body" and the other that exists is "testionial" however my query below only prints the first one. Is it because im fetching the results incorrectly?

<div class="feature-text">
<?php 

$qpp = mysql_query("SELECT * FROM cms_page_part WHERE page_id=$id"); 
$rpp = $qpp->fetch(PDO::FETCH_BOTH);

foreach ($rpp as $row) {
?>
     <div id="col1">
            <p><?php echo $row['name']=='body' ? $row['content_html'] : NULL; ?></p>
        </div>
        <div id="col2">
          <p class="testimonial"><?php echo $row['name']=='sidebar' ? $row['content_html'] : NULL; ?></p>
        </div>
<?php 
}
?>
</div>
+1  A: 

With fetch, you are only fetching one row ; which means you have to call fetch several times to get all the rows.

If you want all the rows in one call, you have to use fetchAll.

Pascal MARTIN
i noticed i left my old sql code in teh top line as well...changed that and added what you said and jobs a gooden. Thanks dude.
Andy
You're welcome :-) Have fun !
Pascal MARTIN