Hi,

I'm using InvisionPB to construct a query and basically generate a custom table. The following is what I have. I can get the query to echo prior to the switch/case but can't get it to display within the case itself. Any ideas?

$this->DB->build( array( 'select' => "m.name",
                                            'from'   => array('members' => 'm'),
                                            'add_join' => array( array('select' => 'p.position',
                                            'from'  => array('wt' => 'p'),
                                            'where' => "m.member_id = p.id",
                                            'type' => 'left',
                                            )
                                                    ),
        'having'        => 'p.position = 41',

                                                )

                                            );

        $this->DB->execute();
        $wt1 = $this->DB->fetch();

        // THIS ECHOS FINE HERE SO THE VALUE DOES EXIST BUT DOESN'T PASS TO THE SWITCH/CASE
        foreach($wt1 as $wt2) {
            echo rtrim($wt2, "41");
 }

    //


$x=$org;
switch ($x)
{
case hto:
        print ("<TABLE BORDER CELLPADDING=3>
            <TR ALIGN=CENTER VALIGN=TOP><br /><TH VALIGN=TOP COLSPAN='1'><center> HEAD");
        print ("</center><br /></TH></TR>");
        // VALUE DOES NOT PRINT BELOW IN TABLE
        print ("<td align='center'>$wt2</td>");
  break;

I've also had to use rtrim to trim the array output - which presents itself as an example as James41 (as if the 41 is being carried in to the array). The value within the "case" that prints is "41" - I lose the "James" part completely?

Recommended Answers

All 3 Replies

Anybody able to assist with this at all? I've tried different ways of posting the variable but it just won't happen. Is this a limitation of using switch?

JayJ, have you tried using return on the variable you want to pass out?

Thanks for the assistance. I worked out the day before what the issue was, which your solution would have assisted with diagnosing. I was pulling the value the wrong way (i.e. the join was a right join and I needed to switch the tables around or use a left join)

Many thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.