Welcome Guest, Not a member yet? Register   Sign In
if statement gone wrong
#1

[eluser]snowstar[/eluser]
Hi all,

Im wondering if some one can point me in the right direction, i've written an if statement which should only print out results if one varable matchs the other. How ever its displays all the information in the table


snippet from my controller

Code:
$data = array();

        if($query = $this->mymodel_model->get_one_data())
        {
            $data['records'] = $query;
        }
        
        
        if($query = $this->mymodel_model->get_one_details())
        {
            $data['drecords'] = $query;
        }

snippet from my View


Code:
<?php if(isset($drecords)) : foreach($drecords as $drow) : ?>
                    
                <?php
                        
                        if ( $row->invnum = $drow->orderid ) {
                ?>
                <tr>
                            <td>&lt;?php echo $drow->prodid; ?&gt;</td>
                            <td>&lt;?php echo $drow->name; ?&gt;</td>
                            <td>&lt;?php echo $drow->des; ?&gt;</td>
                            <td> &lt;?php echo $drow->qty; ?&gt;</td>    
                            <td> &lt;?php echo $drow->price; ?&gt;</td>    
                </tr>
    
                &lt;?php } ?&gt;
                    &lt;?php endforeach; ?&gt;

                    &lt;?php else : ?&gt;    
                    <h2>No Records were found</h2>
                    &lt;?php endif; ?&gt;

Note: $row->invnum is in a for each loop above this and doesnt close till end of page.

Im attempting to only print details that $row->invnum match $drow->orderid, Im not sure where im going wrong

The whole page is a template which is repeated for each result (from parent for each)
#2

[eluser]Rob @ iFetch[/eluser]
'=' != '=='

To elaborate...

"The comparison between $my_name and "someguy" was done with a double equal sign "==", not a single equals"="! A single equals is for assigning a value to a variable, while a double equals is for checking if things are equal." from http://www.tizag.com/phpT/if.php
#3

[eluser]dudeami0[/eluser]
Code:
$data = array();

if(($query = $this->mymodel_model->get_one_data()) !== false) {
   $data['records'] = $query;
}

if(($query = $this->mymodel_model->get_one_details()) !== false) {
   $data['drecords'] = $query;
}

That would possibly work, else something like:
Code:
$data = array();

$query = $this->mymodel_model->get_one_data()
if($query !== false) {
   $data['records'] = $query;
}

$query = $this->mymodel_model->get_one_details()
if($query !== false) {
   $data['drecords'] = $query;
}




Theme © iAndrew 2016 - Forum software by © MyBB