sillysillysilly Posted February 27, 2009 Share Posted February 27, 2009 Simple question on displaying the array results from two columns. this is what I am using to test $result = mysql_query("SELECT dateavail, type From avail WHERE propertyid ='$propertyid' AND (datecheck - $gooddate) > 0"); $num_rows = mysql_num_rows($result); echo $num_rows . "<br />"; if ($num_rows){ $i=0; while ($dateavail = mysql_fetch_row($result)){ echo $dateavail[$i] . "<br />"; } } I get 9 rows and can see dates but cannot see types no matter what different ideas I have tried. Link to comment https://forums.phpfreaks.com/topic/147180-solved-how-to-display-the-results-of-a-query-on-two-columns/ Share on other sites More sharing options...
premiso Posted February 27, 2009 Share Posted February 27, 2009 Your never incrementing $i, so it is always 0. Also the 'type' column will never get displayed because you only have one output. There is really no need for the $i echo $dateavail[0] . "<br />"; echo $dateavail[1] . "<br /><br />"; Should display the data. Link to comment https://forums.phpfreaks.com/topic/147180-solved-how-to-display-the-results-of-a-query-on-two-columns/#findComment-772644 Share on other sites More sharing options...
sillysillysilly Posted February 27, 2009 Author Share Posted February 27, 2009 thanks I need to pass the data to an array that I will later put into a table for display. So should I do something like incrementing $i in the process and saying $firstavail[$i] = $dateavail[0]; $typeavail[$i] =$dateavail[1]; Thanks for your help. Link to comment https://forums.phpfreaks.com/topic/147180-solved-how-to-display-the-results-of-a-query-on-two-columns/#findComment-772652 Share on other sites More sharing options...
sillysillysilly Posted February 27, 2009 Author Share Posted February 27, 2009 Ok I tried the pass to a varaible and got it to work. Thanks for your help. Link to comment https://forums.phpfreaks.com/topic/147180-solved-how-to-display-the-results-of-a-query-on-two-columns/#findComment-772670 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.