A checkbox next to each name allowing me to give a "yes/no" option to add the volunteer to a team.
ex:
Jane Doe Add to Team? (checkbox here)
This is the code for the search:
<h2>Search</h2>
<form name="search" method="post" action="<?php echo $_SERVER['PHP_SELF']?>">
Search for: <input type="text" name="find" /> in
<Select NAME="field" id="field">
<Option VALUE="volskills">Skills</option>
<Option VALUE="txtlname">Last Name</option>
</Select>
<input type="submit" name="btnSearch" value="Search" id="btnSearch" />
<?
if (isset($_POST['btnSearch']))
{
//button has been pressed, lets throw the form data into PHP variables
$errors=0; //used as a flag to check if there are form errors
$find = strtoupper($_POST['find']); //users search term
safe($find); //the function to sanitize the data from sql injection attacks
$find = trim($find);//trim the whitespace out
//for testing
echo "What do we have in find? " . $find;
$field = $_POST['field']; //what selection did they choose?
safe($field);//the function to sanitize the data from sql injection attacks
$field = trim ($field);//trim the whitespace out
//for testing
echo "What do we have in field? " . $field;
//lcheck to see if search field is blankc
if ($find == "")
{
echo "<p>You forgot to enter a search term";
$errors = 1;
exit;
}
//check see if there are no errors
if($errors == 0)
{
//check to see if last name is being searched
if ($field=="txtlname")
{
//lrun our query to search by last name
// echo "we are in the txtlname condition";
$dbhost = 'localhost';
$dbuser = 'softeng13';
$dbpass = '*****';
$dbname = 'softeng13';
$db = DB::connect( "mysql://$dbuser:$dbpass@$dbhost/$dbname" );
$db->setFetchMode(DB_FETCHMODE_ASSOC);
//$sql = "SELECT * FROM volunteers WHERE lname LIKE '$find' ORDER BY lname, fname";
$sql = "SELECT * FROM volunteers WHERE lname LIKE '%$find%' ORDER BY lname, fname";
$demoResult = $db->query($sql);
echo "<h2>Search Results:</h2><br />";
while ($demoRow = $demoResult->fetchRow()) {
echo $demoRow['lname'].", " . $demoRow['fname'] . "<br/>";
}//end while
}//end if lname
if ($field=="volskills")
{
//lrun our query to search by skills
// echo "we are in the txtlname condition";
$dbhost = 'localhost';
$dbuser = 'softeng13';
$dbpass = '******';
$dbname = 'softeng13';
$db = DB::connect( "mysql://$dbuser:$dbpass@$dbhost/$dbname" );
$db->setFetchMode(DB_FETCHMODE_ASSOC);
//$sql = "SELECT * FROM volunteers WHERE lname LIKE '$find' ORDER BY lname, fname";
$sql = "SELECT volunteers.lname, volunteers.fname, skills.skillname FROM volunteers, skills, volskills
WHERE skills.skillname LIKE '%$find%' AND skills.skillid = volskills.skillid AND volskills.vid = volunteers.vid ORDER BY volunteers.lname, volunteers.fname";
$demoResult = $db->query($sql);
echo "<h2>Search Results:</h2><br />";
while ($demoRow = $demoResult->fetchRow()) {
echo $demoRow['lname'].", " . $demoRow['fname'] . " | " . $demoRow['skillname'] . "<br/>";
}//end while
}//end if lname
}//end if errors == 0
}//end if search button has been pressed
?>
</form>
</tr>
</table>
I have absolutely NO clue on how to do this. None. So any help you can offer is so appreciated

New Topic/Question
Reply




MultiQuote





|