Register | Login | |||||
Main
| Memberlist
| Active users
| ACS
| Commons
| Calendar
| Online users Ranks | FAQ | Color Chart | Photo album | IRC Chat |
| |
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 |
| ||
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 |
| ||
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 |
| ||
$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 |
| ||
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 |
| ||
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]."< (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 |
| ||
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] | | | |