How to save values to an array?

Creating php array from mysql query?

  • I have a query in my code which returns several values from the database. Is there any way to put these results into an array. Here is the 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); //To display the results while($row1 = mysql_fetch_array($result1)) { echo $row1['term']; } Is there any way i can save this result into an array?

  • Answer:

    You can do it like that: $all = array(); while ($all[] = mysql_fetch_array($result1)) {}

Don't Be Hasty at Yahoo! Answers Visit the source

Was this solution helpful to you?

Other answers

http://www.jooria.com/dosearch.php?search=mysql&dosearch=search

gege m

Paultech

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.