$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
You're getting the data from your query outside of your loop. That needs to
be part of your loop, otherwise, as you've seen, it just displays the first
record. You could try something like this:
$cnt = 0;
while ($row = mysql_fetch_object($result))
{
echo "$row->file_name$row->file_id";
$cnt+
Well, the for loop is now working but its not displaying what I want. I am
pulling data from a DB and for every new I would like to get the next
result and if it reaches more then 2 columns, to start a new row. This I am
not initally having a problem with. That is the looping. The problem I am
On Wednesday, July 9, 2003, 8:56:17 PM, Micah wrote:
[ snip ]
MM> for ($j=0: $j < 5; $j++) {
that : needs to be a ;
[ snip ]
--
Regards,
Burhan Khalid
phplist[at]meidomus[dot]com
http://www.meidomus.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http
I did it similar but calling some variables and it would never work. I'll
give it a shot again and see what happens and if same thing, I'll post it.
thanks
"Matt Matijevich" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> your syntax is correct, just need to change for ($j=0: $j <
Also u can do nested foreach loops too...
Example:
while( $row = mysql_fetch_array( $result ) ) {
$rows[] = $row;
}
foreach( $rows as $row ) {
foreach( $row as $i => $value ) {
// do stuff here
echo "$i = $value\n";
}
}
I do this tons...
--
bigdog
On Wed, 2003-07
Hi,
I did one once. It was similar to what you typed out here. Are you having
troubles with this?
-Dan Joseph
> -Original Message-
> From: Micah Montoy [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, July 09, 2003 1:56 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] nested for loops
>
your syntax is correct, just need to change for ($j=0: $j < 5; $j++) to
for ($j=0; $j < 5; $j++)
>>> "Micah Montoy" <[EMAIL PROTECTED]> 07/09/03 12:56PM >>>
Anyone ever do a nested for loop?
$i =0;
$j =0;
for ($x=0; $x < 50; $x++){
echo ("1 to 50");
for ($j=0: $j < 5; $j++) {
Simple to fix it. You just need to resolve ambiguity with {}.
> $res = $i * $j;
> $target_array[$i][$j] = $res;
> print("result = $target_array[$i][$j] ");
print("result = {$target_array[$i][$j]} ");
Regards,
--
Yasuo Ohgaki
<[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTE
While it's apparently not always required, I always reccommend (and always
do it personally) that you use a bracket around every function.
So it should lool like this:
");
}
}
?>
It makes it easier to see where the loops begin and where they end, and it
stops most types of errors from appea
You just do something like this:
'.$val."\n";
?>
Just throw arrays into arrays :O)
--Joe
On Fri, Apr 06, 2001 at 11:18:19AM -0600, [EMAIL PROTECTED] wrote:
>
>
> Joe Stump wrote:
> >
> > A copy and paste into foo.php and then a php -q foo.php yielded results for
> > me.
>
> Yeah, it's gi
Joe Stump wrote:
>
> A copy and paste into foo.php and then a php -q foo.php yielded results for
> me.
Yeah, it's giving me results too today. I don't know what went wrong
yesterday.
To extend my question, I'm trying to work with multidimensional arrays.
For example, I would like to do this:
I cut and pasted your code and it worked fine - ???
kirk
> As a test, I did this and it doesn't work. The script simply doesn't
> give any output.
>
> error_reporting(E_ALL);
>
> for( $i=0; $i<10; $i++ )
> for( $j=0; $j<10; $j++ )
> {
> $res = $i * $j;
> print(" result = $res
A copy and paste into foo.php and then a php -q foo.php yielded results for
me.
--Joe
On Fri, Apr 06, 2001 at 10:44:59AM -0600, [EMAIL PROTECTED] wrote:
> Howdy Y'all!
>
> I'm trying to figure out why I'm having so much difficulty with
> nested for loops.
>
> As a test, I did this and it doesn
14 matches
Mail list logo