开发者

Looping - I am just struggling with this

OK, I have stared at this code for hours now scratching my head knowing that there is a way to do what I need to do but am going loopy trying to figure it OUT :/

Basically I have images within a subfolder and each subfolder has a view. What I need to do is output the names of the f开发者_Go百科iles with an appended number in each subfolder with each view.

Now I have the loop working for appending the number to the filenames with a single subfolder type, but what I want to do is iterate trough each subfolder and out put the same thing but for every subfolder instead of just one.

$ticker = "RRST";
$i = 0;
$last = '';

$query = mysql_query( "SELECT * FROM baseimage JOIN art ON base_folder = series_code WHERE art.ticker = '$ticker' ORDER BY base_folder" );
if( !$query ) {
 die( mysql_error() ); 
}

while($row = mysql_fetch_array($query)) {

if( $row['COUNT(base_folder)'] < 1 && $row['image_type'] == 'B' && $row['view'] == 'FF' ) {
    if( $last !== $row['base_folder'] ) {
         $i = 0;
    }
   echo $row['base_folder']."-".$i++;

           echo "<br />";
    $last = $row['base_folder'];
     echo "<hr />";
}

}

Now this is working but I would like to change this line:

if( $row['COUNT(base_folder)'] < 1 && $row['image_type'] == 'B' && $row['view'] == 'FF'

so that the it loops through the multiple ['image_type'] and the multiple ['view'], unstead of hard coding the image_type and view

Can anyone help me with this please?


You could set the expected values of image_type and view in an array and loop through it

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜