elis Posted October 27, 2008 Share Posted October 27, 2008 I have the following snippet (please let me know if I haven't included enough information, I'm trying to minimize the amount of unneeded code and may accidentally delete something pertinent) <?php $sqlr = "SELECT * FROM candidateJoborderHistory ch LEFT JOIN candidatestatus cs ON ch.status_id = cs.status_id LEFT JOIN interviewtypes i ON ch.interview_id = i.interview_id WHERE candidate_id = :cid AND joborder_id = :jid AND status_id = :sid ORDER BY date_updated DESC"; $stmtf = $conn->prepare($sqlr); $stmtf->bindParam(':cid', $id); $stmtf->bindParam(':jid', $job['job_id']); $stmtf->bindParam(':sid', $rowP[5]); $stmtf->execute(); $name_ids = array(); $date_ids = array(); if($stmtf->rowCount() == 0) { $table_row .= ' '; } else { $rowr = $stmtf->fetch(PDO::FETCH_ASSOC); $table_row .=' · ' . convert_datetime($rowr['date_updated']) . '</td></table>'; } Following (and before) this snippet is additional $table_row.=" variables which simply print out HTML tables with information in them. The problem I'm having is I need to create a query that uses three and statements (I believe my syntax is incorrect which is leading to my problem) however, when I include "AND status_id = :sid" in the query, the page loads incorrectly. There are no errors printed, simply the HTML tables I mentioned earlier fail to align properly and the results from the query are not printed. If I use the exact same snippet as above, but remove "AND status_id = :sid" the page displays properly, which leads me to believe the error is in that realm. $id, $job[job_id] and $rowp[5] are all declared before the snippet. $id and $job_[id] are $_GET variables and $rowp[5] is obtained from this query which precedes the former: <?php $qry = "SELECT * FROM interviewFeedback WHERE candidate_id = :id AND joborder = :jid"; $stmtx = $conn->prepare($qry); $stmtx->bindParam(':jid', $job['job_id']); $stmtx->bindParam(':id', $id); $stmtx->execute(); $rowp = $stmtx->fetch(PDO::FETCH_ASSOC); Link to comment https://forums.phpfreaks.com/topic/130341-solved-syntax-help/ Share on other sites More sharing options...
elis Posted October 28, 2008 Author Share Posted October 28, 2008 Anyone? Edit: Actually, I think I may have found another solution - except it sends me into an infinite loop, if anyone could suggest how to fix it: The below snippet occurs directly after the first snippet I posted earlier <?php else { $rowr = $stmtf->fetch(PDO::FETCH_ASSOC); while($job['status_id'] == $rowA[4]){ $table_row .=' · ' . convert_datetime($rowr['date_updated']) . ''; } $table_row .='</td></table>'; } Instead of pulling status_id from MYSQL a second time, I'm reusing an array I pulled earlier, combined with rowA[4] which is a number from a different table than status_id. I'd like, in the case the numbers match, for the HTML tables to continue printing until no match exists. If there is a simpler way to do this, please share. Link to comment https://forums.phpfreaks.com/topic/130341-solved-syntax-help/#findComment-676903 Share on other sites More sharing options...
elis Posted October 28, 2008 Author Share Posted October 28, 2008 Figured it out. Link to comment https://forums.phpfreaks.com/topic/130341-solved-syntax-help/#findComment-676959 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.