Jump to content

NomadicJosh

Members
  • Posts

    190
  • Joined

  • Last visited

Everything posted by NomadicJosh

  1. @richb201 Can you maybe share with us some code that we can look at?
  2. Just like I said, you are missing the ending quotation at the end of the where clause. It should look something like this: <?php $editquery = mysql_query("UPDATE users SET email=$email, password=$password, location=$location, picture=$picture, website=$website, about=$about WHERE user_id='" ._$SESSION['user'] . "'"); ?>
  3. Yes, that is the correct syntax, but in your example, you're missing the closing quotation, so you have to be careful of that.
  4. I think what you need is mysqli_stmt_fetch, and you should also take a look at mysqli_prepare. Those two resources should help steer you into the right direction.
  5. You are using INSERT syntax instead of UPDATE syntax. Your UPDATE query should follow this syntax: UPDATE table_name SET field1=new-value1, field2=new-value2 WHERE field = value;
  6. Sorry, what I should have wrote was this instead: error_log(var_export(mysqli_query( $this->_conn, $query ),true)); If that still does not populate error messages on your server, then if you are using Firefox or Chrome, use the network monitor when submitting the form to make sure the fields being posted match the database fields or see if there is some other problem.
  7. Can you also post the code that is doing the admin check?
  8. I am reposting your code in a much more readable format: public function selectAction($action,$id){ switch($action){ case ('novisibol') : $visibol= 1; if( !$res=$this->_modelAdmin->visibleMenu($visibol,$id)){ echo 'errore nel cambio dello stato'; }else { header ('Location: admin.php?menu'); } break ; case ('visibol') : $visibol= 0 ; if( !$res=$this->_modelAdmin->visibleMenu($visibol,$id)){ echo 'errore nel cambio dello stato'; }else { header ('Location: admin.php?menu'); } public function visibleMenu($id,$visibol){ if( empty($id) ) return false ; if ($visibol > 1) return false ; if ($visibol==0){ $this->_db->update( 'menu',array('menu_visibol'=>1),'menu_id='.$id ); }else { $this->_db->update( 'menu',array('menu_visibol'=>0),'menu_id='. $id ); } return true ; } public function update( $table, $values, $conditions = '1' ){ $first = true; $query = "UPDATE " . $table; $query .= " SET "; foreach( $values as $name => $value ){ if( ! $first ){ $query .= ", "; } $query .= $name . " = " . $value; $first = false; } $query .= " WHERE "; $query .= $conditions; return mysqli_query( $this->_conn, $query ); } In what you call your 3rd class, it seems a bit off, but I am not sure. Before return mysqli_query( $this->_conn, $query ); add this before it: error_log(var_export($query,true)); When the query runs, it will post it to your error log and then you will be able to see if your query is actually doing what you want it to do.
  9. Figured it out. I was missing the data source: success: function(data) {}
  10. I have a dropdown list of departments being pulled from the database. On the same page, you can click a button, a modal form appears and you can add another department if the department you want doesn't exist. After the form is submitted, I need the new value appended to the dropdown list for use. I am not fluent in jquery and ajax at all, so I need help figuring out what is wrong with my code. Below I am pasting each element separately along with the json output as well as the error message. Javascript: <script type="text/javascript"> $(function() { $("#btn_dept").click(function(e) { e.preventDefault(); var deptCode = $("#newDeptCode").val(); var deptTypeCode = $("#deptType").val(); var deptName = $("#deptName").val(); var deptEmail = $("#deptEmail").val(); var deptPhone = $("#deptPhone").val(); var deptDesc = $("#deptDesc").val(); var dataString = 'deptCode='+deptCode+'&deptTypeCode='+deptTypeCode+'&deptName='+deptName+ '&deptEmail='+deptEmail+'&deptPhone='+deptPhone+'&deptDesc='+deptDesc; if(deptCode == '') { $('.success').fadeOut(200).hide(); $('.error').fadeIn(200).show(); } if(deptTypeCode == '') { $('.success').fadeOut(200).hide(); $('.error').fadeIn(200).show(); } if(deptName == '') { $('.success').fadeOut(200).hide(); $('.error').fadeIn(200).show(); } else { $.ajax({ type: "POST", url: "<?=url('/crse/dept/');?>", data: dataString, success: function() { $('#form').fadeOut(200).hide(); $('.success').fadeIn(200).show(); $('.error').fadeOut(200).hide(); $("#deptForm")[0].reset(); $('#deptCode').append($('<option>', { value: data.deptCode, text: deptCode+' '+deptName })); } }); } return false; }); }); </script> Modal Form: <div class="modal fade" id="dept"> <form class="form-horizontal margin-none" id="deptForm" autocomplete="off"> <div class="dialog-form modal-dialog"> <div class="modal-content"> <!-- Modal heading --> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> <h3 class="modal-title"><?=_t( 'Department' );?></h3> </div> <!-- // Modal heading END --> <div class="modal-body"> <div class="error"><?=_t( 'You must fill out the required fields.' );?></div> <div class="success"><?=_t( 'The Department was created successfully.' );?></div> <!-- Group --> <div class="form-group"> <label class="col-md-3 control-label"><font color="red">*</font> <?=_t( 'Department Code' );?></label> <div class="col-md-8"> <input class="form-control" id="newDeptCode" type="text" name="deptCode" required/> </div> </div> <!-- // Group END --> <!-- Group --> <div class="form-group"> <label class="col-md-3 control-label"><font color="red">*</font> <?=_t( 'Department Type' );?></label> <div class="col-md-8"> <?=dept_type_select();?> </div> </div> <!-- // Group END --> <!-- Group --> <div class="form-group"> <label class="col-md-3 control-label"><font color="red">*</font> <?=_t( 'Department Name' );?></label> <div class="col-md-8"> <input class="form-control" id="deptName" type="text" name="deptName" required/> </div> </div> <!-- // Group END --> <!-- Group --> <div class="form-group"> <label class="col-md-3 control-label"><?=_t( 'Department Email' );?></label> <div class="col-md-8"> <input class="form-control" id="deptEmail" type="text" name="deptEmail" /> </div> </div> <!-- // Group END --> <!-- Group --> <div class="form-group"> <label class="col-md-3 control-label"><?=_t( 'Department Phone' );?></label> <div class="col-md-8"> <input class="form-control" id="deptPhone" type="text" name="deptPhone" /> </div> </div> <!-- // Group END --> <!-- Group --> <div class="form-group"> <label class="col-md-3 control-label"><?=_t( 'Short Description' );?></label> <div class="col-md-8"> <input class="form-control" id="deptDesc" type="text" name="deptDesc" /> </div> </div> <!-- // Group END --> </div> <div class="modal-footer"> <button type="submit" id="btn_dept" class="btn btn-icon btn-default"><i></i><?=_t( 'Add' );?></button> <button type="button" data-dismiss="modal" class="btn btn-icon btn-primary"><i></i><?=_t( 'Cancel' );?></button> </div> </div> </div> </form> </div> Dropdown list of departments: <div class="form-group"> <label class="col-md-3 control-label"><font color="red">*</font> <?=_t( 'Department' );?></label> <div class="col-md-8"> <select name="deptCode" id="deptCode" class="selectpicker form-control" data-style="btn-info" data-size="10" data-live-search="true" required> <option value=""> </option> <?php table_dropdown('department', 'deptTypeCode = "acad" AND deptCode <> "NULL"', 'deptCode', 'deptCode', 'deptName'); ?> </select> </div> <a<?=ae('access_forms');?> href="#dept" data-toggle="modal" title="Department" class="btn btn-primary"><i class="fa fa-plus"></i></a> </div> Database Query: $dept = $app->db->department(); foreach($_POST as $k => $v) { $dept->$k = $v; } $dept->save(); $ID = $dept->lastInsertId(); $department = $app->db->department() ->where('deptID = ?', $ID); $q = $department->find(function($data) { $array = []; foreach ($data as $d) { $array[] = $d; } return $array; }); echo json_encode($q); JSON output: {"deptID":"40","deptTypeCode":"ACAD","deptCode":"HIST","deptName":"History","deptEmail":"","deptPhone":"","deptDesc":"","LastUpdate":"2015-07-30 09:33:00"} Error message output in Chrome: Uncaught ReferenceError: data is not defined Any help with figuring this out is greatly appreciated.
  11. Check out this stackoverflow post and see if this may help you with your issue: http://stackoverflow.com/questions/4151743/how-i-change-the-thickness-of-my-hr-tag
  12. If you are wanting to learn more about mysqli and hone in on your skills, you can check out the documentation on php.net: http://php.net/manual/en/book.mysqli.php However, if you are looking to convert your current code from mysql functions to mysqli in a hurry, there was a converter tool on Oracle's website that I believe has been relocated to Github: https://github.com/philip/MySQLConverterTool
  13. In your initial query, you had WHERE id='$tid', but then in the second query when you fixed where clause, you have topic.id=$tid. So first, which one is it? If it is the second one, shouldn't it be topics.id=$tid, with an (s)?
  14. Don't know if there are others here who are familiar with OpenSIS or have used it. Have you tried posting this request over at OpenSIS's forums, if they have one?
  15. I think you are not seeing the results you need because you are setting the sessions on the landing page instead of in the class. I think your login method should look similar to what's below: public function login($username,$password){ //must start a session session_start(); $hashed = $this->get_user_hash($username); if($this->password_verify($password,$hashed) == 1){ /** memberID and firstname variables must be pulled from the database on successful login in order for the sessions to be set. Similar to how you are querying the database for those data elements in your get_user_hash method. */ $_SESSION['loggedin'] = true; $_SESSION['memberID'] = $memberID['memberID']; $_SESSION['firstname'] = $firstname['firstname']; return true; } } The above code will still not give you the results you need, but the comment I've added about the database will help point you into the right direction.
  16. Answers to questions like these will be based on people's personal preference. Some will say Apache, some will say Nginx, others will say Apache with Nginx running as proxy. In all honesty, installing either of them will not yield the results you need unless set up properly and optimized for ultimate performance. In my personal opinion, I would go with Ubuntu 15.04, with Nginx. A websocket client is available in Ubuntu.
  17. @Ajamese, welcome to the community.
  18. The answer hit me smack over the head one night. I can do the following query and leave out the WHERE clause: SELECT drops FROM ( SELECT IFNULL(COUNT(a.status)/SUM(CASE a.status WHEN 'D' THEN 1 ELSE 0 END),0) as drops,YEAR(a.addDate) as year FROM stu_acad_cred a LEFT JOIN course_sec b ON a.courseSection = b.courseSection LEFT JOIN course c ON b.courseID = c.courseID GROUP BY year ) stuDrops GROUP BY year DESC LIMIT 10
  19. Since student drops may not be a consistent data element and the where clause is defined, I think it is best to just remove it because there is no work around for the query as is.
  20. Placing IFNULL around AVG will cause all the results to become zero. Yes, those tables are needed for dynamic filtering.
  21. I've created a course utilization report which is made up of several different MySQL queries. As you know, if a row contains no data, the result is NULL. IFNULL works to combat that, but doesn't work if there is a GROUP BY clause (GROUP BY a.courseSection). So, I need to figure out how to get it to return zero when one of the rows is null. If you look at the line Average Student Drops in the screenshot, you see that there are two cells missing which is throwing off the data. For example, since 2015 is null, everything shifts to the left. Below is the query I am using; any help with this is greatly appreciated. SELECT AVG(drops) FROM ( SELECT IFNULL(COUNT(a.stuAcadCredID),0) as drops,YEAR(a.addDate) as year FROM stu_acad_cred a LEFT JOIN course_sec b ON a.courseSection = b.courseSection LEFT JOIN course c ON b.courseID = c.courseID WHERE a.status IN('D') GROUP BY a.courseSection ) stuDrops GROUP BY year DESC LIMIT 10
  22. Thank you very much @Barand. I can definitely work with that.
  23. Sorry, that probably was confusing. I was using that as an example of how I want the data to return. Using SQLFiddle to return real data, the result should look like this: | # Students (12/FA Cohort) | Year | ------------------------------------- | 1 | 2012 | | 1 | 2013 | | 0 | 2014 | There is only one student (student #12) in the 12/FA cohort that has registrations for 2012 and 2013. The student does not have registrations for 2014 so it should return 0 or NULL.
  24. I have a small database snippet over at SQLFiddle: http://sqlfiddle.com/#!2/9ff722/55 I need help with writing a query that will allow me to track students in a certain cohort from beginning to graduation. I have two tables: application and stu_acad_cred. The application has the start term and the stu_acad_cred are course registrations. If I want to track students in a fall 2012 (12/FA) cohort, then the query must join the two tables; if the student has a start term of 12/FA *and* has registered for 12/FA courses, the student should be counted. I then want to track those student from year to year or term to term to see if the number of students that started in the 12/FA cohort actually decrease overtime. So, the results should return something similar to below. | # Students (12/FA Cohort) | Year | ------------------------------------- | 2 | 2012 | | 2 | 2013 | | 2 | 2014 | I am not sure if this can be done straight forward or with a stored procedure but any help or direction is greatly appreciated.
  25. I am using fullcalendar, and I am trying to position the mouseover. The current css is: .nube { position:absolute; left:0; top:0; z-index:-10000; border:1px solid #DCA; background:#fffAF0; padding:1em; display: none; max-width: 800px; min-width: 100px; line-height: 12px; direction: ltr; box-shadow: none; color: #111; font-size:.8em; } Attached is a screenshot of the issue. Can anyone help me figure out what I need to change in the css above? Thanks.
×
×
  • 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.