I am trying to show alternate text when there is no sub block for a dynamic query
my php
$Db->SetTbsKey('mfgs_reps');
$TBS->MergeBlock('main', 'mfgs_reps', 'SELECT mfg_id,name,specialty,website,city,state FROM mfgs WHERE name LIKE \'%'.$mfr_name.'%\' ORDER BY name');
$insert_flag="";
$result_flag = "yes"; // hide the descriptive text insert after form submitted
// test if we have any reps (( because I'm not smart enough to do flag using 'sub' result ))
$sub_result_flag = "yes"; // hide the descriptive text insert after form submitted
if(!$rep_result=$Db->GetRows($queryreps)){
$sub_result_flag="";
}
$TBS->MergeBlock('sub', 'mfgs_reps', 'SELECT * FROM reps,mfgs_reps WHERE (mfg_id = %p1%) and reps.rep_id = mfgs_reps.rep_id ORDER BY reps.rep_id');
|
my template
<table width="500" border=0 style="margin-left:0px;">
<tr>
<td colspan=2 style="padding-bottom:10px;">
<a href="http://[main.website;magnet=a;mtype=m+m;]" target="_reps">[main.name;block=tr;htmlconv=no;]</a>
  <field>[main.city;magnet=field;noerr;]</field> <field>   [main.state;magnet=field;noerr;]</field>
<table width=500>
<tr>
<td width=10> </td>
<td width=140 >
<a href="http://[sub.website;magnet=a;noerr;]">[sub.name;block=tr;p1=[main.mfg_id];magnet=tr;ifempty='No Reps listed';]</a>
</td>
<td width=360 >
  <field>[sub.city;magnet=field;noerr;]</field> <field>   [sub.state;magnet=field;noerr;]</field>
<field>[sub.phone;magnet=field;noerr;]</field>
<field><br /></field>
<field></field>
</td>
</tr>
<tr>
<th colspan=3 align=center> [var.sub_result_flag;ifempty='No Reps listed';noerr;] </th>
</tr>
</table>
</td>
</tr>
<td colspan=2 align=right style="padding-bottom:10px;"><hr>
</td>
</tr>
</table>
|
The results look like this
---------------------------------------------------------------------
HydroWorx International, Inc. Middleton PA
No Reps listed
Hydrozo (Enviroseal) / BASF Building Systems Shakopee MN
Brendon Garvin Charlestown MA 617-242-2525
Ed Senger Blue Bell PA 610-279-2003
Scott Suttinger Belchertown MA 413-283-4733
No Reps listed
Riverside Hydronics Forth Worth TX
Robert F. Smith, Jr. Auburn NH 603-644-5554
No Reps listed
Zurn Industries, Inc. (Hydromechanics / Plumbing Div.) Erie PA
Woburn MA 781-933-0436
781-933-0436
No Reps listed
-----------------------------------------------------------------------
Can anyone see what's wrong? Or see a simpler way to do this?
Thanks for TBS every day,
TomH