My database is not normalized because I have a tight deadline to get some data online by month's end and do not currently know how to properly normalize a database. With that said however, my DB has 1 table which has approximately 100-120 columns which I set the proper data type and character limits for and maybe 5,500-6000 records (I'm assuming a MySQL DB supports this for 1 table?) My hope is I can get the queries to function so I can place this online and once online I can work with a programmer to optimize the database structure (not too concerned about speed optimization, etc. right now).
Here are some sample results (please note updated SQL query below without blank input):
SELECT * FROM bookdata WHERE Company_Event LIKE '%show%'
AND Classification5 = 'Public'
AND (Classification1 = 'Transportation'
OR Classification2 = 'Transportation'
OR Classification3 = 'Transportation'
OR Classification4 = 'Transportation')
ORDER BY id
<table width="100%" border="1">
<tr><td>ID</td><td>Company/Event Name</td><td>Industry #1</td><td>Industry #2</td><td>Industry #3</td><td>Industry #4</td><td>Type of Show</td></tr>
<tr>
<td>1847</td>
<td><a href="profile.php?id=1847">First Hawaiian International Auto Show</a></td>
<td>Transportation</td>
<td></td>
<td></td>
<td></td>
<td>Public</td>
</tr>
<tr>
<td>3666</td>
<td><a href="profile.php?id=3666">Pennsylvania Auto Show</a></td>
<td>Automotive & trucking</td>
<td>Transportation</td>
<td></td>
<td></td>
<td>Public</td>
</tr>
<tr>
<td>4988</td>
<td><a href="profile.php?id=4988">Virginia Motor Trend International Auto Show</a></td>
<td>Transportation</td>
<td></td>
<td></td>
<td></td>
<td>Public</td>
</tr>
<tr>
<td>5001</td>
<td><a href="profile.php?id=5001">Washington DC Auto Show</a></td>
<td>Automotive & trucking</td>
<td>Transportation</td>
<td></td>
<td></td>
<td>Public</td>
</tr>
</table>
<br>
<a class="current" href="#">1</a>
<span class="paginate">Items per page:</span><select class="paginate" onchange="window.location='/search_results.php?offset=1&ipp='+this[this.selectedIndex].value+'&Company_Event=show&Industry=Transportation&ShowType=Public&search=GO';return false"><option selected value="10">10</option>
<option value="25">25</option>
<option value="50">50</option>
<option value="100">100</option>
</select>
</div>
</td></tr>
</table>
This is what my search_results.php script looks like presently:
<?php
include ("includes/common_vars.php");
require_once ("includes/paginatormod.class.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $SITE_TITLE; ?> | Search Results</title>
<link rel="stylesheet" type="text/css" href="css/master.css" />
</head>
<body>
<?php include ("includes/header.php"); ?>
<?php
$link = mysql_connect("$DB_HOSTNAME1", "$DB_USERNAME1", "$DB_PASSWORD1") or die("Could not connect: " . mysql_error());
mysql_select_db("$DB_NAME1", $link);
//Genrate the pagination
$Pages = new Paginator;
$Pages->showAll = false; // Set true if you want to enable the "Show all results in one page" button.
$whereclause = " WHERE Company_Event LIKE '%".$_REQUEST["Company_Event"]."%'
AND Classification5 = '".$_REQUEST["ShowType"]."'
AND (Classification1 = '".$_REQUEST["Industry"]."'
OR Classification2 = '".$_REQUEST["Industry"]."'
OR Classification3 = '".$_REQUEST["Industry"]."'
OR Classification4 = '".$_REQUEST["Industry"]."')
";
$orderby = " ORDER BY id ";
$sql_initial_count = $basic_sql . $whereclause . $orderby;
$Pages->Total = $sql_initial_count;
$Pages->AllItems = $Pages->getTotal(); // Get the total number of records.
$Pages->Break = 5; // The breaking point of pagination.
$Pages->makePages(); // Build the pages.
// Make your db query here. Include $pages->limit as described in step 8. (i.e. SELECT id,fname,lname FROM employees $pages->limit)
//$sql_get_doctors = $basic_sql;
$paging_limit = $Pages->limit;
$sql=$basic_sql . $whereclause . $orderby . $paging_limit;
//echo $sql; // remove this line to not display sql output
$result_sql_get_events = mysql_query($sql, $link) or die(mysql_error());
$numofrows = mysql_num_rows($result_sql_get_events);
?>
<form>
<i>Your search returned <span style="color:#0066cc; font-weight:bold;"><?php echo $Pages->AllItems; ?></span> results. Jump to page #: <?php echo $Pages->showJump(); ?></i>
<p style="font-size:10px; font-family:Arial, Helvetica, sans-serif; color:#000000;"><?php echo $sql_initial_count; ?></p>
<?php
if ($Pages->AllItems == 0) {
echo "<p class=\"normalDirectoryText\">No results found for query entered. <a href=\"$BASE_URL.index.php\">Try a new search</a>.</p>";
}
?>
<table width="100%" border="1">
<tr><td>ID</td><td>Company/Event Name</td><td>Industry #1</td><td>Industry #2</td><td>Industry #3</td><td>Industry #4</td><td>Type of Show</td></tr>
<?php while ($row = mysql_fetch_array($result_sql_get_events)) { ?>
<tr>
<td><?php echo $row["id"]; ?></td>
<td><a href="<?php echo $BASE_URL."profile.php?id=".$row["id"]; ?>"><?php echo $row["Company_Event"]; ?></a></td>
<td><?php echo $row["Classification1"]; ?></td>
<td><?php echo $row["Classification2"]; ?></td>
<td><?php echo $row["Classification3"]; ?></td>
<td><?php echo $row["Classification4"]; ?></td>
<td><?php echo $row["Classification5"]; ?></td>
</tr>
<?php } // end while ?>
</table>
<br>
<?php echo $Pages->showPages(); // Show the pages. ?>
<?php echo $Pages->showItems(); // Shows the total items per page dropdown box. ?>
<?php mysql_free_result($result_sql_get_events); ?>
</div>
</td></tr>
</table>
</form>
<?php include ("includes/footer.php"); ?>
</body>
</html>