Sorry about that. The columns are identicial in two different tables (different names, same structure), one with 800 records and the other with about 4,000. The table here is "Organization."
Here is the code that searches in the 800 record table, a fairly simple seach for the name of an organization:
<?
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("localhost", "database", "password");
if (!$db)
{
echo "Error: Could not connect to database. Please try again later.";
exit;
}
mysql_select_db("database");
$query = "select * from Organization where ".$searchtype." like '%".$searchterm."%'";
$result = mysql_query($query);
$num_results = mysql_num_rows($result);
echo "<p>Organizations found: ".$num_results."</p>";
for ($i=0; $i <$num_results; $i++)
{
$row = mysql_fetch_array($result);
echo "<p><strong>".($i+1).". Organization Name: ";
echo stripslashes($row["Org_Name"]);
echo "<br></strong><strong>-- Org Address: </strong>";
echo stripslashes($row["Org_Address"]);
(... etc ... with a bunch of other rows following along the same lines ... )
In the manual it mentions that sometimes for large data sets it's better to use "mysql_fetch_row," although I don't know how to apply it and I don't know if it would apply here. Perhaps you could help me out with that, if you think that is a possible solution.
os2al
[[ I reprint the following lines below from the manual about fetch. Perhaps you could adapt it for me, if it applies. I'm not too long in the tooth:
(query = "SELECT * FROM table_name";
$query_result_handle = mysql_query ($query)
or die ('The query failed! table_name must be a valid table name that exists in the database specified in mysql_select_db');
make sure that we recieved some data from our query
$num_of_rows = mysql_num_rows ($query_result_handle)
or die ("The query: '$query' did not return any data");
print "The query: '$query' returned $num_of_rows rows of data.
";
use mysql_fetch_row to retrieve the results
for ($count = 1; $row = mysql_fetch_row ($query_result_handle); ++$count)
{
print "
<b>Fetching row #$count from the query.</b>
";
print "Value stored at the first index position of \$row: '$row[0]'
";
print "Value stored at the second index position of \$row: '$row[1]'
";
print "Value stored at the third index position of \$row: '$row[2]'
";
print "Value stored at the fourth index position of \$row: '$row[3]'
";
print "Value stored at the fifth index position of \$row: '$row[4]'
";
print "Value stored at the sixth index position of \$row: '$row[5]'
";
print '...
';
} ...etc. ]]