Welcome Guest, Not a member yet? Register   Sign In
Get the value from DropDown list [RESOLVED]
#1

(This post was last modified: 12-05-2016, 02:25 PM by Fraps900.)

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'];
Reply
#2

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
Reply
#3

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 =" "')
Reply
#4

(This post was last modified: 12-04-2016, 08:22 AM by ivantcholakov. Edit Reason: fixing a small mistake )

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.
});
Reply
#5

(This post was last modified: 12-03-2016, 02:02 PM by Fraps900.)

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?
Reply
#6

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

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

(This post was last modified: 12-05-2016, 02:11 PM by Fraps900.)

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...
Reply
#8

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.
Reply
#9

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/da...index.html
Reply
#10

(This post was last modified: 12-07-2016, 02:22 PM by Fraps900.)

(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/da...index.html

Thanks Wouter60. Work the same and related to Codeigniter Smile
Reply




Theme © iAndrew 2016 - Forum software by © MyBB