Query and result problem
Posted: Tue Apr 08, 2003 12:01 pm
Hi and a big
to all!
Since my last prob got solved so well i hope someone helps me again (perhaps for a bottle of Vodka
).
Here we go:
I have two MySQL tables - one with project descriptions (i.e. Title, subject, starting date, ...) and another one with the data of the peple working at a single project; both the description and the correlated people have the same (local)id.
In a first query, i look if a project with the id = '1977' exists and if so,
how many peple are working at it. Then, assuming that $anumrows is bigger than zero (in this case, $anumrows is 2)
In this case, the result SHOULD be
but it is
Has anyone an idea which propably saves the poor rest of my nerves???
TiA, bluenote
Since my last prob got solved so well i hope someone helps me again (perhaps for a bottle of Vodka
Here we go:
I have two MySQL tables - one with project descriptions (i.e. Title, subject, starting date, ...) and another one with the data of the peple working at a single project; both the description and the correlated people have the same (local)id.
In a first query, i look if a project with the id = '1977' exists and if so,
Code: Select all
<?php
$aquery = "SELECT publications.id, pub_creator.localid FROM publications LEFT JOIN pub_creator ON publications.id = pub_creator.localid WHERE publications.id = '1977' AND pub_creator.localid = '1977'";
$aerg = MYSQL_QUERY($aquery);
$anumrows = MYSQL_NUM_ROWS($aerg);
if ($anumrows > '0') {
$a = 0;
$id = mysql_result($aerg,$a,"id");
$localid = mysql_result($aerg,$a,"localid");
?>Code: Select all
<?php
for ($i=0; $i < $anumrows; $i++) {
$cq = "cquery".$i;
$ce = "cerg".$i;
$cn = "cnumrows".$i;
${$cq} = "SELECT role, creatornfamily, creatorngiven, creatorini FROM pub_creator WHERE pub_creator.localid = '1977' ORDER BY pub_creator.localid";
${$ce} = MYSQL_QUERY(${$cq});
${$cn} = MYSQL_NUM_ROWS(${$ce});
if (${$cn} > '0') {
$count = "count_".$i;
${$count} = 0;
$creatorrole = "creatorrole_".$i;
$creatornfamily = "creatornfamily_".$i;
$creatorngiven = "creatorngiven_".$i;
$creatorini = "creatorini_".$i;
${$creatorrole} = mysql_result(${$ce},${$count},"role");
${$creatornfamily} = mysql_result(${$ce},${$count},"creatornfamily");
${$creatorngiven} = mysql_result(${$ce},${$count},"creatorngiven");
${$creatorini} = mysql_result(${$ce},${$count},"creatorini");}
echo "<INPUT TYPE="HIDDEN" NAME="creatorrole_$i" VALUE="${$creatorrole}">\n";
echo "<INPUT TYPE="HIDDEN" NAME="creatornfamily_$i" VALUE="${$creatornfamily}">\n";
echo "<INPUT TYPE="HIDDEN" NAME="creatorngiven_$i" VALUE="${$creatorngiven}">\n";
echo "<INPUT TYPE="HIDDEN" NAME="creatorini_$i" VALUE="${$creatorini}">\n";}}
else {
echo "No one working there...";
?>Code: Select all
<INPUT TYPE="HIDDEN" NAME="creatorrole_0" VALUE="Group Leader">
<INPUT TYPE="HIDDEN" NAME="creatornfamily_0" VALUE="Doe">
<INPUT TYPE="HIDDEN" NAME="creatorngiven_0" VALUE="Jon J.">
<INPUT TYPE="HIDDEN" NAME="creatorini_0" VALUE="J. J.">
<INPUT TYPE="HIDDEN" NAME="creatorrole_1" VALUE="Sponsor">
<INPUT TYPE="HIDDEN" NAME="creatornfamily_1" VALUE="Gates">
<INPUT TYPE="HIDDEN" NAME="creatorngiven_1" VALUE="Bill">
<INPUT TYPE="HIDDEN" NAME="creatorini_1" VALUE="B.">Code: Select all
<INPUT TYPE="HIDDEN" NAME="creatorrole_0" VALUE="Group Leader">
<INPUT TYPE="HIDDEN" NAME="creatornfamily_0" VALUE="Doe">
<INPUT TYPE="HIDDEN" NAME="creatorngiven_0" VALUE="Jon J.">
<INPUT TYPE="HIDDEN" NAME="creatorini_0" VALUE="J. J.">
<INPUT TYPE="HIDDEN" NAME="creatorrole_1" VALUE="Group Leader">
<INPUT TYPE="HIDDEN" NAME="creatornfamily_1" VALUE="Doe">
<INPUT TYPE="HIDDEN" NAME="creatorngiven_1" VALUE="Jon J.">
<INPUT TYPE="HIDDEN" NAME="creatorini_1" VALUE="J. J.">TiA, bluenote