Results 1 to 6 of 6

Thread: Photo Section with Text

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

    Default Photo Section with Text

    Just curious how I would go about making the text match an image...this is what I have so far but it doesn't add it to the last image...and also the text is the same for all the images, which I want to be different (or whatever the user supplies):

    Code:
    <?php
    
    if($_SESSION['loggedIn'] == "true")
    {
    	if($action == "edit")
    	{
    		require("conn.php");
    		$img_sql = "select imagefolder from users where username = '$user'";
    		$img_result = mysql_query($img_sql) or die ( mysql_error() );
    					
    		$imgfolder = mysql_result($img_result, 0);
    					
    		$images = glob('./images/' . $imgfolder . '/*.PNG');
    		
    		$pictext = "select pictext from users where username='$user'";
    		$pictext_result = mysql_query($pictext) or die (mysql_error());
    		$pictext = mysql_result($pictext_result, 0);
    		
    		$i = true;
    ?>
    <table style="position: relative; left: 35px;">
    <?php
    		
    		foreach($images as $img)
    		{
    			
    			if($i == true)
    			{
    				//echo "<img src='" . $img . "' style='margin: 0px 5px 0px 5px; border: 1px solid black;' /><br /><input type='text' />";
    				echo "<tr><td><img src='" . $img . "' style='margin: 0px 5px 0px 5px; border: 1px solid black;' /></td>";
    				echo "<td style='display: block; width: 150px;'>&nbsp;</td>";
    			}
    			else
    			{
    				echo "<td><img src='" . $img . "' style='margin: 0px 5px 0px 5px; border: 1px solid black;' /></td></tr>";
    				echo "<tr>
    <td>
    <p>
    ". $pictext . "
    </p>
    </td>
    <td style='display: block; width: 150px;'>
    &nbsp;
    </td>
    <td>
    <p>" . $pictext ."
    </p>
    </td>
    </tr>";
    			}
    			
    			$i = !$i;
    		}
    	}
    }
    
    
    ?>
    </table>
    Also I was wondering if there is a way to add an array-like field in MySQL, cuz I think that would help solve my problem. Thanks in advance!

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

    Default

    I don't thinking:
    PHP Code:
    $i = !$i
    Makes $i false, if its true.
    PHP Code:
    $i true;
    echo 
    $i."<br />";
    $i = !$i;
    echo 
    $i
    Jeremy | jfein.net

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

    Default

    right thats the check it makes to display an image row or a row that has the picture description. It works okay since I have it set up to be on every other row.

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

    Default

    So that means, this variable shouldn't display?
    If thats the case, why not do:
    PHP Code:
    unset($i); //unset the variable 
    Jeremy | jfein.net

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

    Default

    sorry I am still very new to PHP what does unset do? I'm guessing it deletes a variable after it's used..?

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

    Default

    It deletes a variable, whether or not its been used.
    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
  •