1

Alright I have a query and some code to write to a text file:

Is it posible to have say another $query2 and insert that into the same rows as well? If not, how would I go about it.?

2
  • I'm not clear on what "into the same rows" means. Are you trying to combine the results, so that row 1 would consist of data from two queries, or interleave the results, so that row 1 is from query 1, row 2 from query 2, row 3 from query 1, etc? Or something else? Commented May 26, 2011 at 3:06
  • Yeah, In the first code snippet I am writting the query into seperate rows that align under the column headers (this is all for a google products page). I was just wondering if it was possible to insert the data from lets say query2 (which creates a url) into the results as well. Ie. Id, description, seo_keywords, URL (from the new query) Commented May 26, 2011 at 3:09

1 Answer 1

1

so you're trying to insert the results from two queries into the same text file? do the queries return result sets that correspond to each other in some way? If so, then just assign the results of each query to an array and then when you write out to the file, use a foeach on the array.

For example, assuming that both queries return data that can be joined on the card.id field:

while ($row = mysql_fetch_assoc($query1Result)) {
$resultArray1[] = $row;
}

while ($row = mysql_fetch_assoc($query2Result)) {
$resultArray2[] = $row;
}

foreach ($resultArray1[] as $key=>$result) {

File stuff here. Use $result as an assoc array from query1 and $resultArray2[$id] as an assoc array from query2.

}
Sign up to request clarification or add additional context in comments.

1 Comment

Unfortunately categories does not have the card_id in common. I guess I could always try to just make one big query, but that to me is even scarier than just trying to get the data together.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.