darkcarnival Posted April 2, 2006 Share Posted April 2, 2006 hi,probabley a dumb question but I'm curious about this.i have a template class created and its pretty good though it has one limitation, loops. it doesnt work well at all with loops. my solution place the loops in a function and call them in the template, it works.but it seems to kill off the customablity a bit which is where this question comes in.is there a way to draw out the variables made by the loop by plaxcing them into an array?hard to phrase this so i'll write out an example of what i mean:[code]function loop_thing(){//sql query stuff herewhile($row = mysql_fetch_assoc($sql_r)){$results = array($row['colume1'], $row['Colume2'], $row['colume3']);}return $results;}//then to output:$results = loop_thing();echo $result[0]. "<br>";echo $result[1]. "<br>";echo $result[2];[/code]would something like that work?thanks. Link to comment https://forums.phpfreaks.com/topic/6372-loop-question/ Share on other sites More sharing options...
Zane Posted April 2, 2006 Share Posted April 2, 2006 Yes, you can do thisSame script but modified[code]function loop_thing(){//sql query stuff here$results = array();$i = 0;while($row = mysql_fetch_array($sql_r, MYSQL_NUM)){ $results[] = $row[$i];}return $results;}//then to output:$results = loop_thing();echo $result[0]. "<br>";echo $result[1]. "<br>";echo $result[2];[/code] Link to comment https://forums.phpfreaks.com/topic/6372-loop-question/#findComment-23061 Share on other sites More sharing options...
darkcarnival Posted April 2, 2006 Author Share Posted April 2, 2006 thats great to hear :Dthanks. Link to comment https://forums.phpfreaks.com/topic/6372-loop-question/#findComment-23081 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.