Jump to content

about mysql_fetch_array


astralaaron
 Share

Recommended Posts

this is just part of the codeon my news page..what I want to know is why when I have multiple news stories posted only the first one has the table atributes like the bgcolor etc..no matter if i put the bg color in the <td> or the <table>anyone know whats going wrong?

<table width="100%" border="0" bgcolor="#000000"><?phpwhile($rows=mysql_fetch_array($result)){ // Start looping table row ?><td><h2><?php echo $rows['topic'];?> </h2></td><tr><td><p class="welcomebody"><?php echo $rows['detail']; ?></p></td></tr><tr><td><p class="date">id:<?php echo $rows['id']; ?> posted at: <?php echo $rows['datetime'];?> by: <?php echo $rows['name']; ?></p></td></tr></table>

Link to comment
Share on other sites

After <table> tag you need <tr>, but you have <td>.Try wrapping <td><h2><?php echo $rows['topic'];?> </h2></td> in <tr> </tr> .
ahh I did have that before, somehow it got taken out. I put it back in but its still not looping the table attributes.. only the first post has the background color.
Link to comment
Share on other sites

I Don't think that's a good solution, try this:

<table width="100%" border="0" bgcolor="#000000"><?phpwhile($rows=mysql_fetch_array($result)){ // Start looping table row?><tr> <!-- Moved this tr --><td><h2><?php echo $rows['topic'];?> </h2></td><td><p class="welcomebody"><?php echo $rows['detail']; ?></p></td></tr><tr><td><p class="date">id:<?php echo $rows['id']; ?> posted at: <?php echo $rows['datetime'];?> by: <?php echo $rows['name']; ?></p></td></tr><?php} // End loop?></table>

Link to comment
Share on other sites

I Don't think that's a good solution, try this:
<table width="100%" border="0" bgcolor="#000000"><?phpwhile($rows=mysql_fetch_array($result)){ // Start looping table row?><tr> <!-- Moved this tr --><td><h2><?php echo $rows['topic'];?> </h2></td><td><p class="welcomebody"><?php echo $rows['detail']; ?></p></td></tr><tr><td><p class="date">id:<?php echo $rows['id']; ?> posted at: <?php echo $rows['datetime'];?> by: <?php echo $rows['name']; ?></p></td></tr><?php} // End loop?></table>

that works too.I had the end loop outside of the table, so since i had the mysql_fetch_array inside the table it did not work.when I moved it before the table it worked.But when both the end look and the start of the loop is inside of the table it works :-)thanks for that!
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...