SELECT * FROM appointments app LEFT JOIN users usr ON app.employeeid=usr.id WHERE app.appfname LIKE '%<VALUE>%' AND app.afflname LIKE '%<VALUE>%'
I'm confused with this code ?.?
I made a few changes (ie db is now named employees, the other appointments)
@RBA
So that code preps the database correct? Now how would I search the table for first and last name of the appointment in order to display that so kind of how the code would work in my brain:
search.php (display)
Please Enter
First Name: [INPUTBOX]
Last Name: [INPUTBOX]
Search
^This is the first and last name of the person that is visiting that the employee added^
And then it will search the columns to ensure that appointments.appfname and appointments.applname are in the same row and then dump the appointments.employeeid from the same row into a variable that then queries the employees database to pull the requesting employee then display the employees information stored in the db and then the information from the appointment information
Hope that makes sense... Also if there is a better suggestion in the way to go about it...
So would running this be necessary:
jointables.sqlCREATE VIEW app_employee_view AS
SELECT appointments.id, appointments.appfname, appointments.applname, appointments.appphone, appointments.appcompany, appointments.appdate, appointments.appagree, appointments.apprequest, appointments.employeeid, employees.id, employees.employeeid, employees.firstname, employees.lastname, employees.phone, employees.email
FROM appointments
INNER JOIN employees
ON appointments.employeeid=employees.employeeid
updated table
table_employeesCREATE TABLE IF NOT EXISTS `employees` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`employeeid` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`firstname` varchar(20) COLLATE utf8_unicode_ci NOT NULL,
`lastname` varchar(20) COLLATE utf8_unicode_ci NOT NULL,
`phone` varchar(20) COLLATE utf8_unicode_ci NOT NULL,
`email` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`password` char(64) COLLATE utf8_unicode_ci NOT NULL,
`salt` char(16) COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `employeeid` (`employeeid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-----
EDIT
-----
I've been working on a search function (haven't added sqli protection just yet)
search.php<?PHP
// First we execute our common code to connection to the database and start the session
require("common.php");
// We will use this SQL query to locate the first and last name entered in the search
//is there
$query = "
SELECT
`id`, `appfname`, `applname`, `appphone`, `employeeid`
FROM appointments
WHERE
appfname='" . $_POST['appfname'] . "' IN (appfname, applname, appphone, employeeid)
AND
applname='" . $_POST['applname'] . "' IN (appfname, applname, appphone, employeeid)
";
?>
<h1>Search Appointments</h1>
<form action="search.php" method="post">
First Name:<br />
<input type="text" name="appfname" value="" />
<br></br>
Last Name:<br />
<input type="text" name="applname" value="" />
<br></br>
<input type="submit" value="Search" />
</form>
After use the form I get the following PHP Notice's:
PHP Notice: Undefined index: appfname in search.php on line 13
PHP Notice: Undefined index: applname in search.php on line 15
Then once I get the search function working, I still need to do the results page where I can also query the requesting employee based off of the employeeid in the associated row...
Sorry le n00b at mysql with PHP xD