Register | Login
Views: 19364387
Main | Memberlist | Active users | ACS | Commons | Calendar | Online users
Ranks | FAQ | Color Chart | Photo album | IRC Chat
11-02-05 12:59 PM
0 user currently in Programming. | 3 guests
Acmlm's Board - I2 Archive - Programming - Showing all rows [PHP] [MySQL] | |
Add to favorites | "RSS" Feed | Next newer thread | Next older thread
User Post
Darth Coby

Vire
Dacht je nou echt dat het over was?
Dacht je nou echt dat ik gebroken was? Nee toch?
Nou kijk eens goed op uit je ogen gast.
zonder clic heb je geen kloten tjap... bitch
Level: 55

Posts: 183/1371
EXP: 1240774
For next: 73415

Since: 03-15-04
From: Belgium

Since last post: 2 days
Last activity: 9 hours
Posted on 03-26-04 02:39 AM Link | Quote
Is it possible to make an array with lots of arrays inside? I'd need it so I can load all the rows from my table and then print out the values from the rows.
Acmlm

Torosu
heh
Level: 51

Posts: 365/1173
EXP: 981994
For next: 31944

Since: 03-15-04
From: Somewhere that isn't outside of Sherbrooke, Québec, Canada

Since last post: 39 days
Last activity: 3 hours
Posted on 03-26-04 09:35 AM Link | Quote
Of course it can be done

$somearray[test]="hello";
$biggerarray[w00t]=$somearray;
print $biggerarray[w00t][test]; //prints "hello"

Or more specifically:

$res=mysql_query("SELECT * FROM something");
for($i=0;$row[$i]=mysql_fetch_array($res);$i++);

Then $row becomes an array containing all the rows, and $i stops at the number of rows ... and then you can do stuff like this:

print $row[15][test]; //value of "test" field from row 15 (first row would be 0)
Darth Coby

Vire
Dacht je nou echt dat het over was?
Dacht je nou echt dat ik gebroken was? Nee toch?
Nou kijk eens goed op uit je ogen gast.
zonder clic heb je geen kloten tjap... bitch
Level: 55

Posts: 217/1371
EXP: 1240774
For next: 73415

Since: 03-15-04
From: Belgium

Since last post: 2 days
Last activity: 9 hours
Posted on 03-26-04 10:25 PM Link | Quote


$sql = mysql_query("SELECT * FROM kt15x_main");
for($i=0;$row[$i]=mysql_fetch_array($sql, MYSQL_BOTH);$i++);
while($next = next($row)){
print "Date: $row[$i][date]
";
print "IP: $row[$i][ip]
";
print "Visitor number: $row[$i][counter]
";
print "Browser: $row[$i][browser]
";
print "Came from: $row[$i][referer]

";
}



That doesn't work, it just prints "Date: [date]".
What did I do wrong?
Tuvai
Permanently banned for account hacking.
Level: 24

Posts: 114/211
EXP: 74894
For next: 3231

Since: 03-15-04

Since last post: 566 days
Last activity: 339 days
Posted on 03-26-04 11:00 PM Link | Quote
Instead of
print "Date: $row[$i][date]
";


Try
print "Date:".$row[$i][date];


(edited by Tuvai on 03-26-04 02:00 PM)
Acmlm

Torosu
heh
Level: 51

Posts: 377/1173
EXP: 981994
For next: 31944

Since: 03-15-04
From: Somewhere that isn't outside of Sherbrooke, Québec, Canada

Since last post: 39 days
Last activity: 3 hours
Posted on 03-26-04 11:00 PM Link | Quote
Hmm, 2 things here ...

First, $row[$i] in the while loop is empty (else you'd get "array[date]" and so on), try using $next instead or changing the loop ...

And secondly (although that wouldn't matter anymore if you use $next), multidimensional arrays can't be included directly in quotes for printing/etc., so you have to do it like this:

print "Date: ".$row[$i][date]."<br>";


(edited by Acmlm on 03-26-04 02:01 PM)
Darth Coby

Vire
Dacht je nou echt dat het over was?
Dacht je nou echt dat ik gebroken was? Nee toch?
Nou kijk eens goed op uit je ogen gast.
zonder clic heb je geen kloten tjap... bitch
Level: 55

Posts: 218/1371
EXP: 1240774
For next: 73415

Since: 03-15-04
From: Belgium

Since last post: 2 days
Last activity: 9 hours
Posted on 03-26-04 11:27 PM Link | Quote
Well, since $row[$i] was empty I decided to use $next like acmlm told me, it works now. Thanks.
Add to favorites | "RSS" Feed | Next newer thread | Next older thread
Acmlm's Board - I2 Archive - Programming - Showing all rows [PHP] [MySQL] | |


ABII


AcmlmBoard vl.ol (11-01-05)
© 2000-2005 Acmlm, Emuz, et al



Page rendered in 0.014 seconds.