Thanks for the reply. That sort of took care of one of my questions. I was actually going to post both of my questions together but the post was too long so I decided to cut it into two part but it took a while for the thread to post to I took a nap :o
The other problem I have is, I need to make the file that actually goes through and will query the database. That's where my php inexperience is really kicking me in the butt. I made two files
<?php
$sql_host = "localhost";
$sql_user = "username";
$sql_pass = "pass";
$sql_db = "test";
?>
and
<?php
include 'connection_file.php';
if(empty($sql_host) || empty($sql_user) || empty($sql_pass) || empty($sql_db) || !file_exists('connection_file.php')){
echo 'You did not fill in all the required fields in the connection_file.php file or it does not exist in this directory....';
exit();
} else{
mysql_connect($localhost, $username, $pass) or die("Could not connect");
mysql_select_db($test) or die(mysql_error());
function searchForm(){
$searchwords = (isset($_GET['words']) ? htmlspecialchars(stripslashes($_REQUEST['words'])) : '');
$Booth Number = (($_GET['by'] == 'Booth Number') ? ' selected="selected"' : '' );
$Booth Status = (($_GET['by'] == 'Booth Status') ? ' selected="selected"' : '' );
$Roof = (($_GET['by'] == 'Roof') ? 'selected="selected"' : '' );
$Tables = (($_GET['by'] == 'Tables') ? ' selected="selected"' : '' );
$Racks = (($_GET['by'] == 'Racks') ? ' selected="selected"' : '' );
$Platform Type = (($_GET['by'] == 'Platform Type') ? ' selected="selected"' : '' );
echo '<form action="'.$_SERVER['PHP_SELF'].'" method="GET">'."\n";
echo '<input type="hidden" name="cmd" value="search">'."\n";
echo 'Search For: <input type="text" name="words" value="'.$searchwords.'"> '."\n";
echo 'Search By: '."\n";
echo '<select name="by">'."\n";
echo '<option value="Booth Number" '.$Booth Number.'>Booth Number</option>'."\n";
echo '<option value="Booth Status" '.$Booth Status.'>Booth Status</option>'."\n";
echo '<option value="Roof" '.$Roof.'>Roof</option>'."\n";
echo '<option value="Tables" '.$Tables.'>Tables</option>'."\n";
echo '<option value="Racks" '.$Racks.'>Racks</option>'."\n";
echo '<option value="Platform Type" '.$Platform Type.'>Platform Type</option>'."\n";
echo '<input type="submit" value="Search">'."\n";
}
$cmd = (isset($_GET['cmd']) ? $_GET['cmd'] : '');
switch($cmd)
{
default: //If no search words have been entered....
echo '<h1 align=center>Search Database!</h1>'."\n";
echo '<h2>Our Search Form</h2>'."\n";
echo '<p>Type in your keywords below.</p>'."\n";
searchForm();
break;
case "search":
echo '<h1 align=center>Search Results</h1>';
searchForm();
echo '<h3>Search Results:</h3><br />';
$by = $_GET['by'];
$searchstring = mysql_escape_string($_GET['words']);
switch($by){
case "Booth Number":
$sql = "SELECT `Booth Number`, `Booth Status`, `Roof`, `Tables`, `Racks`, `Platform Type`
MATCH(`Booth Number`, `Booth Status`, `Roof`, `Tables`, `Racks`, `Platform Type`)
AGAINST ('$searchstring' IN BOOLEAN MODE) AS score FROM test
WHERE MATCH(`Booth Number`, `Booth Status`, `Roof`, `Tables`, `Racks`, `Platform Type`)
AGAINST ('$searchstring' IN BOOLEAN MODE) ORDER BY score BOOTH NUMBER";
break;
case "Booth Status":
$sql = "SELECT `Booth Number`, `Booth Status`, `Roof`, `Tables`, `Racks`, `Platform Type`
MATCH(`Booth Number`, `Booth Status`, `Roof`, `Tables`, `Racks`, `Platform Type`)
AGAINST ('$searchstring' IN BOOLEAN MODE) AS score FROM test
WHERE MATCH(`Booth Number`, `Booth Status`, `Roof`, `Tables`, `Racks`, `Platform Type`)
AGAINST ('$searchstring' IN BOOLEAN MODE) ORDER BY score BOOTH NUMBER";
break;
case "Roof":
$sql = "SELECT `Booth Number`, `Booth Status`, `Roof`, `Tables`, `Racks`, `Platform Type`
MATCH(`Booth Number`, `Booth Status`, `Roof`, `Tables`, `Racks`, `Platform Type`)
AGAINST ('$searchstring' IN BOOLEAN MODE) AS score FROM test
WHERE MATCH(`Booth Number`, `Booth Status`, `Roof`, `Tables`, `Racks`, `Platform Type`)
AGAINST ('$searchstring' IN BOOLEAN MODE) ORDER BY score BOOTH NUMBER";
break;
case "Tables":
$sql = "SELECT `Booth Number`, `Booth Status`, `Roof`, `Tables`, `Racks`, `Platform Type`
MATCH(`Booth Number`, `Booth Status`, `Roof`, `Tables`, `Racks`, `Platform Type`)
AGAINST ('$searchstring' IN BOOLEAN MODE) AS score FROM test
WHERE MATCH(`Booth Number`, `Booth Status`, `Roof`, `Tables`, `Racks`, `Platform Type`)
AGAINST ('$searchstring' IN BOOLEAN MODE) ORDER BY score BOOTH NUMBER";
break;
case "Racks":
$sql = "SELECT `Booth Number`, `Booth Status`, `Roof`, `Tables`, `Racks`, `Platform Type`
MATCH(`Booth Number`, `Booth Status`, `Roof`, `Tables`, `Racks`, `Platform Type`)
AGAINST ('$searchstring' IN BOOLEAN MODE) AS score FROM test
WHERE MATCH(`Booth Number`, `Booth Status`, `Roof`, `Tables`, `Racks`, `Platform Type`)
AGAINST ('$searchstring' IN BOOLEAN MODE) ORDER BY score BOOTH NUMBER";
break;
case "Platform Type":
$sql = "SELECT `Booth Number`, `Booth Status`, `Roof`, `Tables`, `Racks`, `Platform Type`
MATCH(`Booth Number`, `Booth Status`, `Roof`, `Tables`, `Racks`, `Platform Type`)
AGAINST ('$searchstring' IN BOOLEAN MODE) AS score FROM test
WHERE MATCH(`Booth Number`, `Booth Status`, `Roof`, `Tables`, `Racks`, `Platform Type`)
AGAINST ('$searchstring' IN BOOLEAN MODE) ORDER BY score BOOTH NUMBER";
break;
}
$result = mysql_query($sql) or die (mysql_error());
switch($by){
default:
searchForm();
break;
case "Booth Number":
while($row = mysql_fetch_object($result)){
echo $row->title ."\n<br>";
echo $row->desc ."\n<br>";
echo '<a href="'. $row->link .'">I'll insert link later</a>'."<br>\n";
echo '<hr size="1">'."\n";
}
break;
case "Booth Status":
while($row = mysql_fetch_object($result)){
echo '<a href="'. $row->link .'">I'll insert link later</a>'."\n<br>";
echo '<hr size="1">'."\n";
}
break;
case "Roof":
while($row = mysql_fetch_object($result)){
echo $row->desc ."\n<br>";
echo '<a href="'. $row->link .'">I'll insert link later</a>'."\n<br>";
echo '<hr size="1">'."\n";
}
break;
}
case "Tables":
while($row = mysql_fetch_object($result)){
echo $row->title ."\n<br>";
echo $row->desc ."\n<br>";
echo '<a href="'. $row->link .'">I'll insert link later</a>'."<br>\n";
echo '<hr size="1">'."\n";
}
case "Racks":
while($row = mysql_fetch_object($result)){
echo $row->title ."\n<br>";
echo $row->desc ."\n<br>";
echo '<a href="'. $row->link .'">I'll insert link later</a>'."<br>\n";
echo '<hr size="1">'."\n";
}
case "Platform Type":
while($row = mysql_fetch_object($result)){
echo $row->title ."\n<br>";
echo $row->desc ."\n<br>";
echo '<a href="'. $row->link .'">I'll insert link later</a>'."<br>\n";
echo '<hr size="1">'."\n";
}
}
}
?>
I found this example online and I tried to change the names to the files I'm using. My database is called "test" and the table within is called "booths" I uploaded the file to the server and tried to test it but I got a
error message. That's whats giving me the biggest headache, getting that search file going. Now that I know that I can use the checkbox search form that I wanted, all that's left is getting the search page going and then getting the whole she-bang-bang working as one. Any suggestions, anybody?