Results 1 to 4 of 4

Thread: Adding images into a Layout...

  1. #1
    Join Date
    Nov 2007
    Location
    USA
    Posts
    170
    Thanks
    8
    Thanked 22 Times in 22 Posts

    Default Adding images into a Layout...

    Hey guys,

    I am getting images from what a user uploads and my problem is that when I display them they get displayed in one column going down the page. I would like them to be displayed in 2 columns though. Usually this would be a simple task for me but since there is text that goes with each picture it is throwing me off. Here is the code I wrote:

    Code:
    <?php 
    	$sql = "SELECT * FROM pictures WHERE username = '".$_SESSION['user']."'";
    	$result = mysql_query($sql) or die (mysql_error());
    
    	while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) 
    	{
    	   echo "<a href='".$row['picurl']."'><img src='" . $row["picurl"] . "' width='300' height='300'/></a><br />";
    	   echo $row["pictext"] . "<br /><br />";
    	}
    ?>
    Thanks for any of your thoughts!

  2. #2
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    PHP Code:
    <?php 
        $sql 
    "SELECT * FROM pictures WHERE username = '".$_SESSION['user']."'";
        
    $result mysql_query($sql) or die (mysql_error());
        
    $i=0;

        while (
    $row mysql_fetch_array($resultMYSQL_ASSOC)) 
        {
          ++
    $i;
          if(
    $i==2){ $i 0; }
           echo 
    "<div ".($i==1) ? "style='float:left'" ""."><a href='".$row['picurl']."'><img src='" $row["picurl"] . "' width='300' height='300'/></a><br />";
           echo 
    $row["pictext"] . "<br /><br /></div>";
        }
    ?>
    Thing that should work, didn't test it though.
    Btw, I added a div in there.
    If this script doesn't work send me over ALL of your code.
    Last edited by Nile; 09-23-2008 at 12:12 PM.
    Jeremy | jfein.net

  3. The Following User Says Thank You to Nile For This Useful Post:

    Moshambi (09-23-2008)

  4. #3
    Join Date
    Nov 2007
    Location
    USA
    Posts
    170
    Thanks
    8
    Thanked 22 Times in 22 Posts

    Default

    Dude awesome! I can't believe I didn't think about putting it in a floated div. I had to take out the .($i==1) ? and : ""." cuz it was making it just display the text. But when I removed that it worked exactly how I wanted it to. Thank you so much Nile!

  5. #4
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Your welcome. That's what genies are for, lol jk.
    Jeremy | jfein.net

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •