$query = mysql_query (" SELECT * FROM `tablename`"); $num = mysql_num_rows($query); for($x=0;$x<=$num;$x++) { $result = mysql_fetch_array($query); $var = $result['fldname']; }