Jump to content

Red2034

Members
  • Posts

    19
  • Joined

  • Last visited

Profile Information

  • Gender
    Male
  • Location
    San Francisco

Contact Methods

  • Skype
    eLearnOnline

Red2034's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I am passing a single paramater in, but still trying to figure out how to pass the array in: btn display page code: <?php $classesMaster=$this->db->get('class_master')->result_array(); foreach($classesMaster as $row):?> <tr><td width="50" align="center"> <?php echo form_open('student/classes/enroll' , array($classesMaster));?> <div class="form-actions"> <button type="submit" class="btn btn-gray"> <?php echo get_phrase('enroll');?></button></div></form> controller page code: function classes($param1 = '', $param2 = '', $classesMaster) { if ($param1 == 'enroll') { $data['title'] = $classesMaster['title']; $data['status'] = 'not attempted'; $data['enroll_date'] = date("Y-m-d"); $this->db->insert('class', $data); redirect(base_url() . 'index.php?student/classes/', 'refresh'); } title is still coming up NULL... I get what you are saying about passing the value of $classesMaster into this controller page function (I DO) but I just dont know php well enough to know how to pass and parse the array... I started this project by grabbing some code from several places online and have been piecing them together and for the most part I have made it work but this is the only thing that is not... can you help me a bit more (anyone)?
  2. unfortunately, I was not able to pass along the para. into that classes function... But I did realize that those para already exists on the first page that contains the btn - so I just added the code to the btn itself... <?php $classesMaster = $this->db->get('class_master')->result_array(); foreach($classesMaster as $row):?> <tr><td width="50" align="center"> <button type="submit" class="btn btn-gray"> <?php echo get_phrase('enroll'); $classes = $this->db->get('class_master', ('title'))->row(); $data['title'] = $row['title']; $this->db->insert('class', $data);?></button> so this is adding the title to the 'class' table correctly, but it adds all titles that exists in the 'class_master' table everytime I refresh the page?!?!? and I thought that I would call '$classes' where I have $row listed above but it throws an error. "DataTables warning (table id = 'DataTables_Table_1'): Requested unknown parameter '1' from the data source for row0" any suggestion with this new approach?
  3. but honestly I thought I was declaring $classes with this: $classes = $this->db->get_where('class_master', array( 'title'))->row();
  4. ah! $foo = 'bar'; is not global - this is my issue - let me now play around with these ideas...
  5. do you mean I need to add something like this outside my classes function on the controller page: <?php $classes = $this->db->get('class_master')->result_array(); foreach($classes as $row):?> unsure how to define $classes in PHP i guess?
  6. on one page I have a btn for each row of data (in my case I am showing all the courses available from 'class_master'): <td width="50" align="center"> <?php echo form_open('student/classes/enroll' , array('class_master' => 'form-horizontal validatable','target'=>'_top'));?> <div class="form-actions"> <button type="submit" class="btn btn-gray"><?php echo get_phrase('enroll');?></button> </div> </form> </td>... and on the controller page I am firing the case for the 'enroll' call listed above. Now what I would like to happen is this: I want some of the info from that row selected to INSET into the 'class' table, and here is the code on the controller page: function classes($param1 = '', $param2 = '') { if ($param1 == 'enroll') { $classes = $this->db->get_where('class_master', array( 'title'))->row(); $data['title'] = $classes['title']; $this->db->insert('class', $data); redirect(base_url() . 'index.php?student/classes/', 'refresh'); } if I replace the bold code above with "any text"; it works fine, but the way it is I get this error when I click the btn... Error Number: 1054 Unknown column '0' in 'where clause' SELECT * FROM (`class_master`) WHERE `0` = 'title' Filename: /public_html/Site/controllers/student.php Line Number: 97 does anybody have any suggestions about what may be wrong
  7. thanks everyone for the help so far! I amlost have this working and because of the help this newbe understands php that much better... that said, here my last issue: title is coming up NULL - i guess I am not defining $classes correctly.... Can anyone explain this better or help me with this code below? I am trying to insert the title of only the row that an 'enroll' btn is associated with... if ($param1 == 'enroll') { $classes = $this->db->get_where('class_master', array('title'))->row(); $data['title'] = $classes['title']; $this->db->insert('class', $data); redirect(base_url() . 'index.php?student/classes/', 'refresh'); }
  8. <?php function enroll() { $classes = $this->db->get('class')->result_array(); if($_POST['action'] == 'call_this') { $data['title'] = $row['title']; $this->db->insert('class', $data); }} ?> <script language="javascript"> function fireEnroll() { $.ajax({ url: '<?php echo base_url().'index.php?student/classes/'; ?>', data: {action: 'call_this'}, type: 'post', success: function(output) { alert(output); } }); } </script> ... <?php $classesMaster = $this->db->get('class_master')->result_array(); foreach($classesMaster as $row): ?> <tr> <td width="50" align="center"> <a href="" class="btn btn-default btn-small" onclick="fireEnroll()" > <?php echo get_phrase('enroll');?> </a> </td> ... tried this to 'expose $row' to what I want but still no worky....
  9. ok - so i think im close: <?php function enroll() { if($_POST['action'] == 'call_this') { $data['title'] = $row['title']; $this->db->insert('class', $data); redirect(base_url() . 'index.php?student/classes/', 'refresh'); }} ?> <script language="javascript"> function fireEnroll() { $.ajax({ type: "POST", url: "base_url() . 'index.php?student/classes/'", data:{action:'call_this'}, success:function(html) { alert(html); } }); } </script> html <a href="" class="btn btn-default btn-small" onclick="fireEnroll()" > <?php echo get_phrase('enroll');?> </a> this is firing the js func which posts to the php and does the redirect as the last call of the php, but it does not add the data to the table?!?!? seems like a cludggy was to go about this...
  10. multiple 'employees' can have the same item - is it possible to list more than one 'employee_ID' in a row or record?
  11. First off - thanks for the help, so i have made a php function with the previous code: function classes($param1 = '', $param2 = '') { if ($param1 =='enroll') { $data['title'] = $row['title']; $data['deep_link'] = $row['deep_link']; $data['delivery_method'] = $row['delivery_method']; $data['status'] = 'not attempted'; $data['description'] = $row['description']; $data['enroll_date'] = date("Y-m-d"); $this->db->insert('class', $data); }... and then edited the <a href... <a href="#" class="btn btn-default btn-small" onclick="classes($param1 = 'enroll');" > <?php echo get_phrase('enroll');?> </a> hmmm - but still not working... I guess I'll google 'how to call a php function with an HREF now
  12. I have a 'masterList' table that hold all the records of items (obvious) - then I have a 'myList' table that holds all my items I have selected... this is working well - but I was short-sighted in my design because now I want to add many other users that can choose from the 'masterList' let's call then 'employees'. Question - what is now the best way to structure the hierarchy for the many users that will make their own 'myList'??? Thanks for the advice!
  13. So, I am displaying a masterList table of all my records and using a btn in each row to try to INSERT only that row into another table. Here what I have so far: <?php $classes = $this->db->get('class')->result_array();?> <?php $classesMaster = $this->db->get('class_master')->result_array(); foreach($classesMaster as $row):?> <tr> <td width="50" align="center"> <a href="index.php" onclick="<?php $data['title'] = $row['title']; $data['enroll_date'] = date("Y-m-d"); $this->db->insert('class', $data);?>" > <?php echo get_phrase('enroll');?> </a> </td>... everytime I launch the page it INSERTs all the records from my masterList into the other table... Do you see my mistake? Thanks in advance!
  14. why is my INSERT code firing when I reload the page? I put it in an <a href tag hoping it would only fire if I clicked the btn??? <a href="index.php" onclick"<?php $data['title'] = $row['title']; $data['enroll_date'] = date("Y-m-d"); $this->db->insert('class', $data);?>"> <?php echo get_phrase('enroll');?> </a>
  15. let me simplify: I would like to copy certain data from one table to another and I have dumbed down my example to understand this a bit better: <?php $classes = $this->db->get('class')->result_array();?> <?php $classesMaster = $this->db->get('class_master')->result_array(); foreach($classesMaster as $row):?> <a href="index.php"><?php echo get_phrase('enroll'); $classesMaster['title'] = $classes->input->post['title'];?> </a> <?php endforeach;?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.