| By: Billy Date: 2007-05-19 Time: 00:48 | Sub/Dinamyc query not working, can anyone help?Hello, 
I'm trying to use the sub/dinamyc query, but it doesn't seems to work.
 
Here's what I'm doing:
 | // retrieve semesters $semesters = do_query("SELECT *, a.name AS semester_name, b.name AS class_name FROM ssm_semesters a JOIN ssm_classes b ON a.semester = b.semester JOIN ssm_registrations c ON b.class = c.class WHERE c.username = '" . $_SESSION['user']['username'] . "' AND end_semester >= NOW() ORDER BY a.semester DESC");
 
 // manually connect to mysql to use on template
 $mysql_connect = mysql_connect($mysql['host'],$mysql['username'],$mysql['password']) or die("Error connecting to server: " . mysql_error());
 mysql_select_db($mysql['database'],$mysql_connect) or die("Error selecting database: " . mysql_error());
 
 require_once("../includes/tbs_plugin_html.php");
 
 $tbs = new clsTinyButStrong;
 $tbs->NoErr = true;
 $tbs->LoadTemplate("../templates/students_classes.html");
 $tbs->MergeBlock("semesters", $semesters);
 $tbs->MergeBlock("classes", $mysql_connect, "SELECT *, a.name AS class_name FROM ssm_classes a JOIN ssm_semesters b ON a.semester = b.semester WHERE a.semester = '%p1%' AND (a.class = '%p2%' OR a.max_students > (SELECT COUNT(username) FROM ssm_registrations WHERE class = a.class)) ORDER BY a.name ASC");
 $tbs->Show();
 
 | 
And on the HTML side:
 | <tr> <td>[semesters.semester_name;block=tr;when [semesters.available]=0]</td>
 <td>[semesters.class_name] ([semesters.timeblock])</td>
 <td>No</td>
 </tr>
 <tr>
 <td>[semesters.semester_name;block=tr;when [semesters.available]=1;p1=[semesters.semester];p2=[semesters.class]]</td>
 <td>
 <select name="class[[semesters.semester]]">
 <option value="[classes.class;block=option]">[classes.class_name]</option><option>[semesters.class;ope=html;select]</option>
 </select>
 </td>
 <td>[semesters.available]</td>
 </tr>
 
 | 
I always get no results in the drop-down. While running the query on phpMyAdmin I get some results though. | 
	
      | By: Billy Date: 2007-05-19 Time: 01:29 | Re: Sub/Dinamyc query not working, can anyone help?Nevermind, just noticed my mistake by taking a close look to examples. :)
 The parameters should be declared on the sub-block (of course!).
 |