1

I am developing a gallery website where users can visit images that other people have shared. I have created the gallery and images can be viewed using thumbnails and the images upload from the right of the previsous image. If an image is at the edge of the page the next image will go in the row beneath it. I use this code to do this:

<?php
        mysql_connect("localhost","root","");
        mysql_select_db("pardeepsandhu");

        $res= mysql_query("select * from images");
        $row=mysql_fetch_array($res)
?>
<div id="w">
  <div id="content">
      <div id="images"><?php while ($row=mysql_fetch_array($res)){?>
        <a href="<?php echo $row["Image"]; ?>"><img src="<?php echo $row["Image"]; ?>" height="134.1175" width="134.1175" border="5" alt="turntable" /></a>
<?php } ?>
</div>
  </div>
</div>
<script type="text/javascript">
$(function() {
    $('#images a').lightBox();
});
</script>

However, i am now trying to get a voting system set up. At the bottom of each image there would be a button which will give an image a like. The button works however the images, with the buttons, are being laid out differently. All the images appear one beneath the other, it looks like they are in on column. I don't want this to happen as space will be wasted. This is the code with a button:

<div id="w">
  <div id="content">
      <div id="images"><?php while ($row=mysql_fetch_array($res)){?>
        <a href="<?php echo $row["Image"]; ?>"><img src="<?php echo $row["Image"]; ?>" height="134.1175" width="134.1175" border="5" alt="turntable" /></a>
        <form id="form1" name="form1" method="post" action="">

          <input type="submit" name="button" id="button" value="Like this image" />
        </form>

<?php } ?>

How do I get the images to load like they did before, so that they appear in rows rather than in one column. Can anyone help me?

Anton
  • 2,282
  • 26
  • 43
psandhu
  • 65
  • 2
  • 6

1 Answers1

0

To achieve a horizontal layout, you will need to use the css "display:inline-block;" on all of your image / link containers. If I were you, I would have another div which contains all the image and voting info. Also, please make sure you are closing all of your divs as this can dramatically change your layout.

Something along the lines of this should get them horizontal.

<div id="pic" style="display: inline-block;">
<a href=""><img src=""></a>
<form></form>
</div>

http://jsfiddle.net/u9gSD/

korono89
  • 216
  • 2
  • 4