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 Quote 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) Quote 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']); Quote 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. Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.