mysql - PHP get data from database, and use it outside while loop -
<?php $q=select * students (dynamic user searching) $qry=mysql_fetch_array($q); while($row=mysql_fetch_array()) { **// not need data here?** } ?> < table> < tr>< td><?php echo **$row[?][?];** ?>< /td>< td><?php echo **$row[?][?];** ?>< /td>...< /tr> < tr>< td><?php echo **$row[?][?];** ?>< /td>< td><?php echo **$row[?][?];** ?>< /td>...< /tr> .... < /table> in need generate dynamic report in html table format html table rows , columns static results cant use echo in while loop have access out side while loop have idea of selecting single row single column each cell of table separatly time consuming , length alternative or solution?
you don't have use while loop. can fetch data need it.
$row1 = mysql_fetch_array($qry); $row2 = mysql_fetch_array($qry); i don't doing though because have keep track of resource ($qry in case) , have keep typing mysql_fetch_*() tend load results array before use them.
$result = array(); while($row=mysql_fetch_object($qry)) { $result[] = $row; }
Comments
Post a Comment