Hi,
I am trying to get a php page to give 2 sets of results from 2 tables but using a single search.
The code below returns the correct data from the first part of the query, but the second part returns the following error:
"Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/serve/database/playerdata.php on line 96"
This argument comes up twice as you can see.
Thanks for any help.
<?
// We can include this file in all our files
// this way, every file will contain all our functions
require_once("menu_fns.php");
require_once("site_fns.php");
do_html_header("");
do_html_menu("");
do_html_subheader("");
?>
<?
if (!$searchtype || !$searchterm)
{
echo "You have not entered search details. Please go back and try again.";
exit;
}
$searchtype = addslashes($searchtype);
$searchterm = addslashes($searchterm);
@ $db = mysql_pconnect( 'server', 'userid', 'password' );
if (!$db)
{
echo "<CENTER>Error: Could not connect to database. Please try again later.</CENTER>";
exit;
}
mysql_select_db("database");
$query = "select * from madc_ratings where ".$searchtype." like '%".$searchterm."%'";
$result = mysql_query($query);
$num_results = mysql_num_rows($result);
$header = mysql_fetch_array($result);
echo "<TR><TD>";
echo "<CENTER><FONT FACE=Arial SIZE=-3>Number of players found: '.$num_results.'</FONT></CENTER><BR>";
echo "<Table border=0 width=100% ALIGN=CENTER>";
echo "<TR VALIGN=middle>";
echo "<H1>First Name: ";
echo ($header["rfirst"]);
echo "</H1></TR>";
echo "<TR VALIGN=middle>";
echo "<H1>Last Name: ";
echo ($header["rlast"]);
echo "</H1></TR>";
echo "<TR VALIGN=middle>";
echo "<H1>PDGA Number: ";
echo ($header["rpdga"]);
echo "</H1></TR>";
echo "<TR VALIGN=middle>";
echo "<H1>MADC Player Rating: ";
echo ($header["rmadcr"]);
echo "</H1></TR>";
echo "<TR VALIGN=middle>";
echo "<H1>Events Used: ";
echo ($header["eventcount"]);
echo "</H1></TR>";
echo "<TR VALIGN=middle>";
echo "<H1>PDGA Player Rating: ";
echo ($header["pdgar"]);
echo "</H1></TR>";
echo "<TR VALIGN=middle>";
echo "<H1>Rounds Used: ";
echo ($header["prdu"]);
echo "</H1></TR>";
echo "<TR VALIGN=middle>";
echo "<H1>State: ";
echo ($header["rst"]);
echo "</H1></TR></TABLE>";
?>
<!--/*<?
if (!$searchtype || !$searchterm)
{
echo "You have not entered search details. Please go back and try again.";
exit;
}
$searchtype = addslashes($searchtype);
$searchterm = addslashes($searchterm);
@ $db = mysql_pconnect@ $db = mysql_pconnect( 'server', 'userid', 'password' );
if (!$db)
{
echo "<CENTER>Error: Could not connect to database. Please try again later.</CENTER>";
exit;
}
mysql_select_db("database");
$query = "select * from results where ".$searchtype." like '%".$searchterm."%'";
$result = mysql_query($query);
$num_results = mysql_num_rows($result);
echo "<TR><TD>";
echo "<CENTER><p>Number of records found: '.$num_results.'</p></CENTER>";
echo "<Table border=0 width=720 ALIGN=CENTER>";
echo "<TR VALIGN=middle>";
echo "<TD BGCOLOR=#33CCCC ALIGN=left><FONT FACE=Arial SIZE=-3>Event</FONT></TD>";
echo "<TD BGCOLOR=#33CCCC ALIGN=left><FONT FACE=Arial SIZE=-3>Date</FONT></TD>";
echo "<TD BGCOLOR=#33CCCC ALIGN=left><FONT FACE=Arial SIZE=-3>Place</FONT></TD>";
echo "<TD BGCOLOR=#33CCCC ALIGN=left><FONT FACE=Arial SIZE=-3>Div</FONT></TD>";
echo "<TD BGCOLOR=#33CCCC ALIGN=left><FONT FACE=Arial SIZE=-3>First Name</FONT></TD>";
echo "<TD BGCOLOR=#33CCCC ALIGN=left><FONT FACE=Arial SIZE=-3>Last Name</FONT></TD>";
echo "<TD BGCOLOR=#33CCCC ALIGN=left><FONT FACE=Arial SIZE=-3>PDGA</FONT></TD>";
echo "<TD BGCOLOR=#33CCCC ALIGN=left><FONT FACE=Arial SIZE=-3>R1</FONT></TD>";
echo "<TD BGCOLOR=#33CCCC ALIGN=left><FONT FACE=Arial SIZE=-3>R2</FONT></TD>";
echo "<TD BGCOLOR=#33CCCC ALIGN=left><FONT FACE=Arial SIZE=-3>R3</FONT></TD>";
echo "<TD BGCOLOR=#33CCCC ALIGN=left><FONT FACE=Arial SIZE=-3>R4</FONT></TD>";
echo "<TD BGCOLOR=#33CCCC ALIGN=left><FONT FACE=Arial SIZE=-3>Sub</FONT></TD>";
echo "<TD BGCOLOR=#33CCCC ALIGN=left><FONT FACE=Arial SIZE=-3>F9</FONT></TD>";
echo "<TD BGCOLOR=#33CCCC ALIGN=left><FONT FACE=Arial SIZE=-3>Tot</FONT></TD>";
echo "<TD BGCOLOR=#33CCCC ALIGN=left><FONT FACE=Arial SIZE=-3>Prize</FONT></TD>";
echo "<TD BGCOLOR=#33CCCC ALIGN=left><FONT FACE=Arial SIZE=-3>ERating</FONT></TD></TR>";
for ($i=0; $i < $num_results; $i++)
{
$row = mysql_fetch_array($result);
echo "<TR><TD bgcolor=#CCCCCC><FONT FACE=Arial SIZE=-3>";
echo ($row["event"]);
echo "</FONT></TD><TD bgcolor=#CCCCCC><FONT FACE=Arial SIZE=-3>";
echo ($row["edate"]);
echo "</FONT></TD><TD bgcolor=#CCCCCC><FONT FACE=Arial SIZE=-3>";
echo ($row["pl"]);
echo "</FONT></TD><TD bgcolor=#CCCCCC><FONT FACE=Arial SIZE=-3>";
echo ($row["div"]);
echo "</FONT></TD><TD bgcolor=#CCCCCC><FONT FACE=Arial SIZE=-3>";
echo ($row["first"]);
echo "</FONT></TD><TD bgcolor=#CCCCCC><FONT FACE=Arial SIZE=-3>";
echo ($row["last"]);
echo "</FONT></TD><TD bgcolor=#CCCCCC><FONT FACE=Arial SIZE=-3>";
echo ($row["pdgan"]);
echo "</FONT></TD><TD bgcolor=#CCCCCC><FONT FACE=Arial SIZE=-3>";
echo ($row["rd1"]);
echo "</FONT></TD><TD bgcolor=#CCCCCC><FONT FACE=Arial SIZE=-3>";
echo ($row["rd2"]);
echo "</FONT></TD><TD bgcolor=#CCCCCC><FONT FACE=Arial SIZE=-3>";
echo ($row["rd3"]);
echo "</FONT></TD><TD bgcolor=#CCCCCC><FONT FACE=Arial SIZE=-3>";
echo ($row["rd4"]);
echo "</FONT></TD><TD bgcolor=#CCCCCC><FONT FACE=Arial SIZE=-3>";
echo ($row["sub_tot"]);
echo "</FONT></TD><TD bgcolor=#CCCCCC><FONT FACE=Arial SIZE=-3>";
echo ($row["fnl9"]);
echo "</FONT></TD><TD bgcolor=#CCCCCC><FONT FACE=Arial SIZE=-3>";
echo ($row["tot"]);
echo "</FONT></TD><TD bgcolor=#CCCCCC><FONT FACE=Arial SIZE=-3>";
echo ($row["prize"]);
echo "</FONT></TD><TD bgcolor=#CCCCCC><FONT FACE=Arial SIZE=-3>";
echo ($row["madcr"]);
echo "</FONT></TD></TR>";
}
echo "</TABLE>";
?>*/-->
</body>
</html>