Variable representation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Everyone:

I am assigning the value of 4 images to variables following a database query: 

$image_1 = stripslashes( $row['image_1'] );
$image_2 = stripslashes( $row['image_2'] );
$image_3 = stripslashes( $row['image_3'] );
$image_4 = stripslashes( $row['image_4'] );

What I need help with is how to represent the variable using $i for the number portion in the following WHILE loop.  I am not sure of how to correctly do it.  I am referring to: $image_{$i}

===
$i = 1;
while ( $i <= 4 ) {

    if ( trim( $image_{$i} ) <> "" ) { 
    
        echo "<li><a href=\"http://www.theverseoftheday.info/store-images/"; . $image_{$i} . "\" title=\"Image " . $i . "\">Image " . $i . "</a></li>\r\n";
                        
    }

++$i;
}
===

How do I substitute $i for the # so I may use a WHILE loop to display the images?  (Not all 4 variables have an image.)

Ron Piggott



www.TheVerseOfTheDay.info 

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux