Results 1 to 2 of 2

Thread: how to differentiate rows

  1. #1
    Join Date
    Jul 2009
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default how to differentiate rows

    after calling an array, how do i do different each row?

    i would like to show the first image in the gallery and hide the other images

    PHP Code:
    <?php 
    $query 
    "SELECT * FROM residential, res_images WHERE residential.id = $id AND prop_id = $id";         
    $result = @mysqli_query ($db$query); 
    $num_rows mysqli_num_rows($result); 

    while (
    $row mysqli_fetch_array($resultMYSQLI_ASSOC)) { 
        
    $path "archive/res/$id"
        
    $image_name $row['image_name']; 
         
        if (
    blah blah) { 
            echo 
    "<a href='$path/$image_name' rel='lightbox-test'><img src='$path/$image_name' width='140px' /></a>"
        } else { 
            echo 
    "<a href='$path/$image_name' rel='lightbox-test' class='hidden'></a>"
        } 


    mysqli_free_result ($result); 
    mysqli_close($db); 
    ?>

  2. #2
    Join Date
    Mar 2007
    Location
    New York, NY
    Posts
    557
    Thanks
    8
    Thanked 66 Times in 66 Posts

    Default

    Not too sure what you're looking to do,can you be more specific? From what I understood,you're trying to keep only the first image,and no other row results after that will have the image -- only data.

    If that's the case,this should work for you:
    PHP Code:
    <?php  
    $query 
    "SELECT * FROM residential, res_images WHERE residential.id = $id AND prop_id = $id";          
    $result = @mysqli_query ($db$query);  
    $num_rows mysqli_num_rows($result);  

    while (
    $row mysqli_fetch_array($resultMYSQLI_ASSOC)) {  
        
    $path "archive/res/$id";  
        
    $image_name $row['image_name'];  
          
        if (
    $firstImgCalled == 'true') {  
            echo 
    "<a href='$path/$image_name' rel='lightbox-test'><img src='$path/$image_name' width='140px' /></a>";  
        } else {  
            echo 
    "<a href='$path/$image_name' rel='lightbox-test' class='hidden'></a>";  
        }  

        
    $firstImgCalled "true"// this declaration will stop all other imgs from showing via the if...else statement.
    }  

    mysqli_free_result ($result);  
    mysqli_close($db);  
    ?>
    HTH
    - Josh

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
  •