knowram Posted April 28, 2007 Share Posted April 28, 2007 Give that I am self thought I am still trying to learn some of the simple things. Is it possible to write a query statement that will return the entire table (all rows)? $result = mysql_query("select * from [i]Table[/i]") or die ("nope1"); $row=mysql_fetch_array($result); only returns the first row of the table. And or is there a way to select a column and return what ever is in that column from all rows? Thanks for the help. Link to comment https://forums.phpfreaks.com/topic/49098-another-simple-query-question/ Share on other sites More sharing options...
papaface Posted April 28, 2007 Share Posted April 28, 2007 Yeah: $result = mysql_query("select * from Table ") or die ("nope1"); while($row=mysql_fetch_array($result)) { //echo results } Link to comment https://forums.phpfreaks.com/topic/49098-another-simple-query-question/#findComment-240543 Share on other sites More sharing options...
pocobueno1388 Posted April 28, 2007 Share Posted April 28, 2007 <? $query = mysql_query("SELECT col FROM tbl_name"); while ($row = mysql_fetch_assoc($query)){ echo $row['col'] . '<br>'; } ?> Link to comment https://forums.phpfreaks.com/topic/49098-another-simple-query-question/#findComment-240546 Share on other sites More sharing options...
knowram Posted April 28, 2007 Author Share Posted April 28, 2007 Cool Now I know that I could use that loop to push each returned value into a single variable but is there a query that will return it as a single variable already? Link to comment https://forums.phpfreaks.com/topic/49098-another-simple-query-question/#findComment-240550 Share on other sites More sharing options...
taith Posted April 28, 2007 Share Posted April 28, 2007 theoretically... yes... $query = mysql_query("SELECT col FROM tbl_name"); while ($row = mysql_fetch_assoc($query)){ $array[]=$row; } print_r($array); now you got a HUGE array of every row from your database... Link to comment https://forums.phpfreaks.com/topic/49098-another-simple-query-question/#findComment-240555 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.