Jon,
Thanks for the reply. Calling mysql_num_rows in the way you suggest still
produces the error
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result
resource
My adjusted code is below. I am thinking the Good way must be to store what
I need in a throwaway array and not nest the queries.
Thanks for any advice!
jg
foreach ($clients as $id => $client) {
$i = 0;
$result = mysql_query("SELECT PID, Name FROM projects WHERE ID = '$id'");
$NumRows_1 = mysql_num_rows($result);
while ($i < $NumRows_1) {
$PIDs[$id]['ClientName'] = $client;
$PIDs[$id]['ProjectName'] = mysql_result($result, $i, 'Name');
$PIDs[$id]['PID'] = mysql_result($result, $i, 'PID');
$thisPID = $PIDs[$id]['PID'];
$PIDresult = ("SELECT * from hours WHERE PID = '$thisPID'") or
die(mysql_error());
$j=0;
$NumRows_2 = mysql_num_rows($PIDresult);
while ($j < $NumRows_2) {
$PIDs[$id]['PID']['Comments'] = mysql_result($PIDresult, $j,
'Comments');
//make an array of Session info and add to $PIDs
$j++;
}
$i++;
}
}
"Jon Kraft" <jo*@jonux.co.uk> wrote in message
news:bj************@ID-175424.news.uni-berlin.de...
jerrygarciuh <de*****@no.spam.nolaflash.com> wrote:
Hi all,
I am iterating through a result set to generate a second set of queries
but no matter what I do I get the error
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result
resource
Hi Jerry,
You should call mysql_num_rows() only once.
while ($i < mysql_num_rows($result)) {
$NumRows_1 = mysql_num_rows($result);
while ($i < $NumRows_1) {
$PIDs[$id]['ClientName'] = $client;
$PIDs[$id]['ProjectName'] = mysql_result($result, $i, 'Name');
$PIDs[$id]['PID'] = mysql_result($result, $i, 'PID');
$thisPID = $PIDs[$id]['PID'];
$PIDresult = ("SELECT * from hours WHERE PID = '$thisPID'") or
die(mysql_error());
$j=0;
while ($j < mysql_num_rows($PIDresult)) {
$NumRows_2 = mysql_num_rows($PIDresult)
while ($j < $NumRows_2) {
[snip]
HTH;
JOn