dmcdaniel Posted August 4, 2010 Share Posted August 4, 2010 I am having a problem with my PHP/MySQL coding and I can not figure out what I am doing wrong. I have two tables in a database. One called EmployeeInfo and another called Absence. In the Employee Info table, I have two employees, Derek and Adrian. In the Absence table, I have two records, One for Derek and Adrian. Goal: Using PHP/MySQL, I want to call upon an employee using a form and display that person's absence. The form pulls up correctly. If I do NOT put a WHERE clause into my SQL statement, it pulls up all the absences perfectly fine. Once I put in the WHERE = EmployeeInfo.Name = 'NameSelect' then it fails every time. Here is my SQL Coding: $result = mysql_query("SELECT * FROM Absence LEFT JOIN EmployeeInfo ON(Absence.Account = EmployeeInfo.Account) WHERE EmployeeInfo.Name='NameSelect'"); Any help is greatly appreciated. Link to comment https://forums.phpfreaks.com/topic/209805-phpmysql-help/ Share on other sites More sharing options...
radar Posted August 4, 2010 Share Posted August 4, 2010 here is a sample of a left join that i use with a where clause, and other stuff too. $sql = "SELECT SQL_CALC_FOUND_ROWS cust.id, cust.f_name, cust.l_name, cust.email, cust.password, cust.optin, cust.status, o.c_id, d.d_id, COUNT( o.id ) AS orders_cnt, COUNT( d.id ) AS deals_cnt FROM customers AS cust LEFT JOIN orders AS o ON o.c_id = cust.id LEFT JOIN deals AS d ON d.d_id = cust.id WHERE cust.l_name LIKE '".$_pid."%' GROUP BY o.c_id, d.d_id ORDER BY cust.l_name LIMIT ".Paginate::getCurrentIndex().", ".Paginate::getLimit(); Link to comment https://forums.phpfreaks.com/topic/209805-phpmysql-help/#findComment-1095178 Share on other sites More sharing options...
dmcdaniel Posted August 4, 2010 Author Share Posted August 4, 2010 I tried using a LIKE statement but that didn't work either. Not sure if it is something in my view.php code from the form but I created a select query and gave it the name NameSelect so it should all be working properly. Not Sure why its not. Maybe if I pull the NameSelect into a variable. I will give that a shot and see. Link to comment https://forums.phpfreaks.com/topic/209805-phpmysql-help/#findComment-1095195 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.