Nested query

I see, that is very clever to do what you did. I see now that it should work since it is a properly formatted query. I will go back to my page and check out why I am getting an error on the query. thanks a million.

one more quick question… if I may impose?

is the “1” standing for as a boolean or as a string?
(bare with me I am still pretty green to the whole web programing scene)

ok Cool, I got it working…
I changed the “1” in the WHERE clause to “$userid” and voila!!! works like a charm after I inserted an if staement to filter the NULL values.

here it is for those who might be interested or were following:

<?php 
		$userid = $user->data()->id;
		$rss = DB::getInstance()->query(" SELECT fscomponents.componentTitle, fscomponents.id, a.attendee FROM (SELECT fscomponents.componentTitle,fsattendances.attendee 
			FROM fscomponents LEFT JOIN fstraining 	ON fscomponents.id = fstraining.FSComponentId 
			LEFT JOIN fsattendances ON fstraining.fireSafetyId = fsattendances.fireSafetyId 
			WHERE fsattendances.attendee = $userid) AS a RIGHT JOIN fscomponents ON a.componentTitle = fscomponents.componentTitle");
		

		if($rss->count()){
			
			echo '<table>';
				echo '<th class="th">Fire Safety Component</th>';
					echo '<tr>';
					  foreach($rss->results() as $lists){
						  if($lists->attendee == NULL){
						  echo	'<td class="tdLeft"> <a  href="firesafety.php?id='.escape($lists->id).'">'.escape($lists->componentTitle).'</a></td>';
						  }
					echo '</tr>';	
					  }	
		}else{echo 'There is no existing Fire Training Component at the monent';}
		echo'</table>';
		?>
    </section>

Mucha Gracias Amigo StarLion

2 Likes

Sorry yes, forgot to replace that when i did the copy/paste out of my test run. the “1” was the user ID.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.