Re: nested for loops

From: Date: Wed, 09 Jul 2003 19:16:56 +0000
Subject: Re: nested for loops
Groups: php.general 
Request: Send a blank email to php-general+get-154621@lists.php.net to get a copy of this message
<snip> $result = mssql_query("SELECT * FROM files WHERE file_id = '$cat_name' ORDER BY file_name ASC"); $i = $col_num; $j = 0; $filename= mssql_result($result,0,"file_name"); $fileID = mssql_result($result,0,"file_id"); for ($k = 0; $k < mssql_num_rows($result); $k++) { //changes row color if (fmod($k, 2)){$rowColor = "$oddcolor";}else{$rowColor = "$evencolor";} echo ("<TR bgcolor=$rowColor>"); for ($j = 0; $j < $i; $j++) { echo ("<td><a href=index.php&ID=$fileID_id>$filename</a>". "Name: <strong>$getimage_name</strong>". "<a href='index.php&ID=$fileID">Delete</a></td>"); } echo ("</TR>"); } </snip> Unless I am misuderstainding what you want to do, you need to reassign $filename and $fileID_id variables in your loop somewhere using the mssql_result function. The way the loop is working now they will be the same throught the entire loop.

« previous php.general (#154621) next »