CodeIgniter Forums
Get the value from DropDown list [RESOLVED] - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Model-View-Controller (https://forum.codeigniter.com/forumdisplay.php?fid=10)
+--- Thread: Get the value from DropDown list [RESOLVED] (/showthread.php?tid=66788)

Pages: 1 2


Get the value from DropDown list [RESOLVED] - Fraps900 - 12-02-2016

hi there,

is there any possible to get the value (on live) from this:

Code:
<div class="form-group">
        <label for="milestone_id"><?=$this->lang->line('application_milestone');?></label>
        <?php   $milestones = array();
                $milestones['0'] = '-';
                 foreach ($project->project_has_milestones as $milestone):
                    $milestones[$milestone->id] = $milestone->name;
                endforeach;
        if(isset($task)){$milestone_selected = $task->milestone_id;}else{$milestone_selected = "";}
        echo form_dropdown('milestone_id', $milestones, $milestone_selected, 'style="width:100%" class="chosen-select"');?>
</div>

To this?

Code:
$result = mysql_query('SELECT SUM(estimated_hours) AS value_sum FROM project_has_tasks WHERE milestone_id ="???????????????"');
$row = mysql_fetch_assoc($result);
$sum = $row['value_sum'];



RE: Get the value from DropDown list - Wouter60 - 12-02-2016

Absolutely.

In your controller:
PHP Code:
$milestone_id $this->input->post('milestone_id');
$this->db
->select('SUM(estimated_hours) as value_sum')
->
from('project_has_tasks')
->
where('milestone_id'$milestone_id);
$sum $this->db->get()->row()->value_sum



RE: Get the value from DropDown list - Fraps900 - 12-03-2016

Thanks for help, but can You please tell me where exactly I could use above code, and how it should looks like in full? Sorry, I'm new in codeigniter Smile

I just need to get the value from chosen select ($milestone->id) to milestone_id =" "')


RE: Get the value from DropDown list - ivantcholakov - 12-03-2016

Code:
// JavaScript
$('#milestone_id').on('change', function() {

    var milestone_id = $(this).val();
    alert(milestone_id); // Remove this line for testing.

    // Then by using jQuery make an AJAX request
    // and refresh the dependent HTML fragment.
});



RE: Get the value from DropDown list - Fraps900 - 12-03-2016

Ok guys maybe this way. Can you help me to get/save/remember <?=$milestone->id;?>, and post this to another id?
I have these numbers here
Code:
<?=$milestone->id;?>
in
Code:
<div class="row tab-pane fade" role="tabpanel" id="milestones-tab">

I have to save this in memory Smile and transfer to this:
Code:
div class="row tab-pane fade" role="tabpanel" id="burndown-tab">


i could get this by:
Code:
            <?php if(isset($milestone)){  ?>
  <input id="id" type="text" name="id" value="<?php echo $milestone->id; ?>" />
<?php } ?>

But How to send it?


RE: Get the value from DropDown list - Wouter60 - 12-04-2016

Send it where?
To your database?
In a session variable?

What do you want to do with the value of the input field?


RE: Get the value from DropDown list - Fraps900 - 12-05-2016

I've put the values to the URL:
Code:
<a href="<?=base_url()?>burndown?id=<?=$milestone->id;?>&id22=<?=$milestone->name?>&id33=<?=$project->name;?>"data-toggle=""><i class="ion-ios-heart milestone__header__right__icon"></i></a>

I got it like:
Code:
    <?php echo $_GET["id"];
    $sum1 = $_GET["id"];
    ?>
    
    <?php echo $_GET["id22"];
   $sum2 = $_GET["id22"];    
    ?>
    
    <?php echo $_GET["id33"];
   $sum3 = $_GET["id33"];    
    ?>

Thanks for the suggestions. It's working good Smile

Anyway Can you please tell me how put these values to Myssql querry?
I have to use
Code:
<?php echo $_GET["id"];?>

in

Code:
<?php

$result = mysql_query('SELECT SUM(estimated_hours) AS value_sum FROM project_has_tasks WHERE milestone_id ="(((HERE))))"');
$row = mysql_fetch_assoc($result);
$sum = $row['value_sum'];
{
echo $sum;
}
?>

Any suggestions?
Just simple put there
Code:
$_GET["id"]
,
Code:
$id"
dosent work...


RE: Get the value from DropDown list - Fraps900 - 12-05-2016

Ok done:
I had to change the querry for:
Code:
$result = mysql_query("SELECT SUM(estimated_hours) AS value_sum FROM project_has_tasks WHERE milestone_id ='$sum1'");
$row = mysql_fetch_assoc($result);
$sum = $row['value_sum'];
?>


CASE CLOSED.


RE: Get the value from DropDown list [RESOLVED] - Wouter60 - 12-05-2016

The solution you've found, has nothing to do with CodeIgniter.
If you set up CI correctly, you can use the Query Builder to make it a lot easier:

PHP Code:
$sum1 $this->input->get('id');
$this->db->sum('estimated_hours','value_sum');
$this->db->where('milestone_id'$sum1);
$sum $this->db->get()->row()->value_sum

$this->db is the database connection CodeIgniter is using.
Please read the Database Reference: http://www.codeigniter.com/userguide3/database/index.html


RE: Get the value from DropDown list [RESOLVED] - Fraps900 - 12-07-2016

(12-05-2016, 11:39 PM)Wouter60 Wrote: The solution you've found, has nothing to do with CodeIgniter.
If you set up CI correctly, you can use the Query Builder to make it a lot easier:

PHP Code:
$sum1 $this->input->get('id');
$this->db->sum('estimated_hours','value_sum');
$this->db->where('milestone_id'$sum1);
$sum $this->db->get()->row()->value_sum

$this->db is the database connection CodeIgniter is using.
Please read the Database Reference: http://www.codeigniter.com/userguide3/database/index.html

Thanks Wouter60. Work the same and related to Codeigniter Smile