0

Hi there, just a quick one (I think), a little stock on displaying PHP results in a div rather than a table. I seem to be managing to display one of the results ok but the rest are not showing, I want them all to display in their own divs. Please see the code below:

<?php
include ("connectionTest.php");
$product = mysql_query("SELECT pagename,content,metaTitle FROM pages");
         $res = mysql_fetch_array($product);
{
echo '<div class="productPrice">'.$res['pagename'].'<br />
        <span class="bigPrice">'.$res['metaTitle'].' </span><br /></div></a>';
}
?>

Can't work out what's wrong though. Always a great deal of help on this forum so look forward to a reply. Appreciate your time.

3
Contributors
5
Replies
6
Views
6 Years
Discussion Span
Last Post by teedoff
0

Well Im limited in my knowledge of php, but In order to ehco dynamic query results, I would think you would at least need a loop.

0

Hi there, thanks for your message. How can I achieve a loop? Apologies, I'm still learning in regards to PHP.

0

Whats wrong with displaying the query results in a dynamic table? Thats what they're actully used for instead of complete page layouts like alot of ppl use them for.

You can still wrap the table in a div if you want and style it that way.

0

One thing I noticed is that you have { on line 5 and } on line 8. I don't know if these are supposed to be part of a if statement or something but they should not be there alone. Are you sure that your query is returning anything?

You can check the array that your query is returning with

<pre>
print_r($res);
</pre>
0

I bet the {} was there because he originally had a dynamic table with a do loop around the query results. When he took the table out, along with the do loop, then thats why he has the curly brackets left and why ony the first query results displays as he said.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.