Jump to content

[SOLVED] Storing mysql query results into a php array.


dont_be_hasty

Recommended Posts

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 :)

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.