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
Other answers
http://www.jooria.com/dosearch.php?search=mysql&dosearch=search
gege m
here is a good idea http://www.w3schools.com/php/php_arrays.asp
Paultech
Related Q & A:
- How to pass javascript jQuery variable value in php array?Best solution by Stack Overflow
- How to do a MySQL recursive query?Best solution by Stack Overflow
- How to write a query for PHP and MySQL?Best solution by Stack Overflow
- How to make a MySql query faster?Best solution by Stack Overflow
- How to start creating a php script, that will be installed on many servers?Best solution by Stack Overflow
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
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.