dont_be_hasty Posted February 11, 2009 Share Posted February 11, 2009 I basically have some code with queries my database and displays the results on a php webpage. I have the following tables in my database: term(id, term) product(id, product) join_table(term_id, product_id) Here is my code: $query1="SELECT term FROM term INNER JOIN join_table ON join_table.term_id=term.id INNER JOIN product ON join_table.product_id=product.id WHERE product = '$product1'"; $result1=mysql_query($query1) or die(mysql_error()); $row1 = mysql_fetch_array($result1); while($row1 = mysql_fetch_array($result1)) { echo $row1['term']; } This code display serveral terms on the screen. Is there any way in which i can save these into an array so that i can count how many terms are returned from the query. Thanks Link to comment https://forums.phpfreaks.com/topic/144770-solved-storing-mysql-query-results-into-a-php-array/ Share on other sites More sharing options...
peranha Posted February 11, 2009 Share Posted February 11, 2009 See if this works for you mysql_num_rows($result1) Link to comment https://forums.phpfreaks.com/topic/144770-solved-storing-mysql-query-results-into-a-php-array/#findComment-759651 Share on other sites More sharing options...
redarrow Posted February 11, 2009 Share Posted February 11, 2009 try this. count($row1['term']); Link to comment https://forums.phpfreaks.com/topic/144770-solved-storing-mysql-query-results-into-a-php-array/#findComment-759653 Share on other sites More sharing options...
dont_be_hasty Posted February 11, 2009 Author Share Posted February 11, 2009 mysql_num_rows($result1) - worked. Thanks. Link to comment https://forums.phpfreaks.com/topic/144770-solved-storing-mysql-query-results-into-a-php-array/#findComment-759691 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.