[SOLVED]Execute a query with the output of another

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
bluenote
Forum Commoner
Posts: 93
Joined: Sat Mar 01, 2003 4:59 am
Location: Heidelberg, Germany

[SOLVED]Execute a query with the output of another

Post by bluenote »

Hi there,

i hope my subject header is not too confusing; what i mean is the following:

I have a script (almost a template) which grabs content (images, text, references a.s.o.) denpending on the passed parameters (company, department, chapter, page number, stanza ...) out of a database; the script is used for every department in the comapny and it is working well.

The problem is that i have to execute sub-queries (for example, to provide additional information about how many people are working in Department 1 - to be displayed in chapter 2, page 3, stanza 11) after the main query.

Is it possible to enter a query code into a DB table and to print or echo it out into a script AND to execute it there?

P.S.: To the moderators: Please don't be :twisted: if this post belongs to another forum.

Thanx in advance for help,
- bluenote
Last edited by bluenote on Sun Nov 14, 2004 3:35 pm, edited 1 time in total.
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

Is it possible to enter a query code into a DB table and to print or echo it out into a script AND to execute it there?
You might have to elaborate a bit more on this as i'm not sure how it relates to the original question of doing sub queries :o
User avatar
bluenote
Forum Commoner
Posts: 93
Joined: Sat Mar 01, 2003 4:59 am
Location: Heidelberg, Germany

Post by bluenote »

Hi mark,

well OK, sorry. The last thing
Is it possible to enter a query code into a DB table and to print or echo it out into a script AND to execute it there?
is the problem to be solved. What i meant with subqueries was that the 'main' query looking like

Code: Select all

<?php
$department = $_REQUEST["department"];
$chapter = $_REQUEST["chapter"];
$siteID = $_REQUEST["siteID"];

$rquery = "SELECT DBgaps.gaps_departments.* from DBgaps.gaps_departments WHERE DBgaps.gaps_departments.dep_g03 = '$department' AND DBgaps.gaps_departments.dep_g04 = '$chapter' AND DBgaps.gaps_departments.dep_g07 = '$siteID' ORDER BY DBgaps.gaps_departments.dep_g08";

$rerg = MYSQL_QUERY($rquery);

$rnumrows = MYSQL_NUM_ROWS($rerg);

if ($rnumrows > '0'){
	
	$r = 0;

...

...

?>
brings up the data to be on display on the webpage (i. e. Department 1, Page 2, Stanzas 1 - 11). Each stanza has its own MySQL table row. In stanza 9, i want to add the information about how many people are working in Department 1, which can change daily. So i want to add a query which should extract the number of people working there into the content table.

- bluenote
Post Reply