Welcome Guest, Not a member yet? Register   Sign In
How should I handle these variables and forms?
#4

[eluser]danbirlem[/eluser]
I've gone and made the input pass the ID, which leads to a database query. What you wrote was the perfect start for me to work off of! I'm still new to programming, anyways.

My question now; how do I make this query only run if there's a check on the page before? It runs across all the inputs, and gives an error when no value is passed, so I need to establish some kind of conditional statement. I was thinking an if statement with isset()?

Code:
<? $field = $this->input->post('measure',true);
$totals = array();

    foreach($field as $value):
        $query = $this->db->get_where('items', array('id' => $value['input']))->row();
    
        $totals[] = $query->price; ?>
        
#HTML for displaying the item goes here
    
    <?php endforeach; ?>
    

<? $grand_total = array_sum($totals); ?>

<p>&lt;?=$grand_total?&gt;</p>


Messages In This Thread
How should I handle these variables and forms? - by El Forum - 03-23-2010, 05:05 PM
How should I handle these variables and forms? - by El Forum - 03-23-2010, 08:21 PM
How should I handle these variables and forms? - by El Forum - 03-26-2010, 10:31 AM
How should I handle these variables and forms? - by El Forum - 03-26-2010, 11:56 AM



Theme © iAndrew 2016 - Forum software by © MyBB