I've run into some problems with people who code and use:
"mysql_numrows()"
I do know that mysql_num_rows() works 100%. Perhaps that is where you're getting mixed up, but I'm pretty sure it's not.
Some comments in your code would not only help me/others, but you as well. But to take a short look, let's do this:
foreach ($composer as $user_name) {
You start a loop for each composer as user_name.
$result = mysql_query("SELECT * FROM compositions WHERE user_name='$user_name' $instrument_search_string year BETWEEN '$y_min' AND '$y_max' AND length BETWEEN '$l_min' AND '$l_max' ORDER BY last_name",$db) or die("Query Error: ".mysql_error());
You set the query. Fine.
$num=mysql_num_rows($result);
You define the number of rows that the query returns.
if ($num==0)
{
continue;
}
If mysql doesn't return rows, DISPLAY ERROR and move to next user_name.
else
{
if ($myrow = mysql_fetch_array($result)) {
Otherwise, if $myrow can fetch the array, let's do something.
printf("<tr><td><font color=\"#333333\" size=\"3\" face=\"Arial, Helvetica, sans-serif\"><br>%s, %s<br></font></td>", $myrow["last_name"], $myrow["first_name"]);
echo "<table border=0 bgcolor=\"#CCCCCC\">\n";
Print out the name of the composer.
do {
printf("<tr><td><font color=\"#333333\" size=\"2\" face=\"Arial, Helvetica, sans-serif\">'%s' for %s %s %s </font></td>", $myrow["title"], strp_char($myrow["instrumentation"]), sec2hms($myrow["length"]), $myrow["year"]);
}
Print out the song info. . .
while ($myrow = mysql_fetch_array($result));
. . .while $myrow is fetching an array for the current result
echo "</table>\n";
}
}
}
Finish the table definition, and close ALL brackets (including the loop bracket).
$num=mysql_numrows($result);
if ($num==0) {
echo "<font color=\"#333333\" size=\"2\" face=\"Arial, Helvetica, sans-serif\">No records found! Please modify your search.</font>";
echo "<br><p><font size=\"2\" face=\"Arial, Helvetica, sans-serif\"><a href=\"catalogue.php\">Return to search page</a></font></p>";
exit;
}
Now, outside the foreach() loop you specify an error for a variable that will get checked once, the last time you go through it. This probably should replace your first if($num == 0) definition, and the exit; should be replaced with continue;
You could also do this another way. You could write a function that prints out all the information you want. Then, IF the number is NOT zero, call the function, if so, then show the error.
~Brett