Jump to content

[SOLVED] Syntax help


elis

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.