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 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.