tags:

views:

96

answers:

3

When showing data from a mysql table on an php page does it have to be in a table??

What I want to do is display my results in divs.

like so:

  <div class="moviebox rounded"><a href="">
  <img src="  $imgurl  " />
  <form method="get" action="">
 <input type="text" name="link" class="link" style="display:none" value="http://us.imdb.com/Title?   $imdburl      "/>
 </form>
  </a></div>

And have that repeat for each one of the images in the database. How is this done?? I am fine showing the data in a table but can't seem to get this right

+3  A: 

When showing data from a mysql table on an php page does it have to be in a table??

No, it is just data. You can describe it using whatever markup you like. A table is often a good choice, but not always.

  <div class="moviebox rounded"><a href="">
  <img src="  $imgurl  " />
  <form method="get" action="">

a elements cannot contain form elements (or any other block element)

David Dorward
A: 

Try:

<div class="moviebox rounded"><a href="">
  <img src="<?= $imgurl ?>" />
  <form method="get" action="">
 <input type="text" name="link" class="link" style="display:none" value="http://us.imdb.com/Title?&lt;?= $imdburl ?>"/>
 </form>
  </a></div>
Lucas Jones
Don't suggest short open tags
kemp
Why not? The `<?=` form is almost always available, and much nicer (IMHO).
Lucas Jones
+1  A: 

like this

<?php
    $result = mysql_query("SELECT imageURL from ...");
    while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
        ?>
            <div>
                <img src="<?php echo $row['imageURL']; ?>" />
            </div>
        <?php
    }
?>
rodrigoap
Shouldn't you be using a numeric array index with MYSQL_NUM flag?
kemp