PHP - Sum Total Amount Paid By Specific Student When They Have Paid More Than Twice
I have mysql table titled fee_payment.
details of the table:
fee_payment Table
payment_id student_id name class term year date amount
1 6 john JHS2 2nd_term 2013 23-04-2013 56 67
2 6 john JHS2 2nd_term 2013 23-04-2013 56 34
3 5 peter JHS3 3rd_term 2014 23-04-2014 56 85
4 6 john JHS2 2nd_term 2014 23-04-2014 56 76
5 6 john JHS2 3rd_term 2014 23-04-2014 56 34
6 6 john JHS2 2nd_term 2014 23-04-2014 56 23
7 5 peter JHS2 3rd_term 2014 23-04-2014 56 43
what i need to do now is to sum total amount paid by each student so that i can view payment records based on term and year.
what i have tried:
Controller:
/******MANAGE FEE PAYMENTS / INVOICES WITH STATUS*****/
function payfees($param1 = '', $param2 = '', $param3 = '') { if ($this->session->userdata('admin_login') != 1) redirect(base_url(), 'refresh'); if ($param1 == 'create') { $data['student_id'] = $this->input->post('student_id'); $data['name'] = $this->input->post('name'); $data['class_id'] = $this->input->post('class'); $data['term'] = $this->input->post('term'); $data['year'] = $this->input->post('year'); $data['amount'] = $this->input->post('amount'); $data['creation_timestamp'] = strtotime($this->input->post('date')); $this->db->insert('fee_payment', $data); redirect(base_url() . 'index.php?admin/payfees', 'refresh'); } if ($param1 == 'do_update') { $data['student_id'] = $this->input->post('student_id'); $data['class_id'] = $this->input->post('class'); $data['term'] = $this->input->post('term'); $data['year'] = $this->input->post('year'); $data['amount'] = $this->input->post('amount'); $data['creation_timestamp'] = strtotime($this->input->post('date')); $this->db->where('payment_id', $param2); $this->db->update('fee_payment', $data); redirect(base_url() . 'index.php?admin/payfees', 'refresh'); } else if ($param1 == 'edit') { $page_data['edit_data'] = $this->db->get_where('fee_payment', array( 'payment_id' => $param2 ))->result_array(); } if ($param1 == 'delete') { $this->db->where('payment_id', $param2); $this->db->delete('fee_payment'); redirect(base_url() . 'index.php?admin/payfees', 'refresh'); } $page_data['page_name'] = 'payfees'; $page_data['page_title'] = get_phrase('fee_payment'); $this->db->order_by('creation_timestamp', 'term'); $page_data['payments'] = $this->db->get('fee_payment')->result_array(); $this->load->view('index', $page_data); } The Invoice: <div class="box-content"> <?php foreach($edit_data as $row):?> <div class="pull-left"> <span style="font-size:20px;font-weight:100;"> <?php echo get_phrase('payment_to');?> <img width="50" height="30" src="<?php echo base_url();?>uploads/logo.png" style="max-height:100px;margin:20px 0px;" /> </span> <br /> <?php echo $system_name;?> <br /> <?php echo $this->db->get_where('settings' , array('type'=>'address'))->row()->description;?> </div> <div class="pull-right"> <span style="font-size:20px;font-weight:100;"> <?php echo get_phrase('credited_account:');?> </span> <br /> <?php echo $this->db->get_where('student' , array('student_id'=>$row['student_id']))->row()->name;?> <br /> <?php echo get_phrase('student_id');?> : <?php echo "FAVECSID0000", $this->db->get_where('student' , array('student_id'=>$row['student_id']))->row()->student_id;?> <br /> <?php echo get_phrase('class');?> : <?php $class_id = $this->db->get_where('student' , array('student_id'=>$row['student_id']))->row()->class_id; echo $this->db->get_where('class' , array('class_id'=>$class_id))->row()->name; ?> </div> <div style="clear:both;"></div> <hr /> <table width="100%" background="http://localhost/sch...backlogos.png"> <tr style="background-color:#7087A3; color:#fff; padding:5px;"> <td style="padding:5px;"><?php echo get_phrase('payment_details');?></td> <td width="30%" style="padding:5px;"> <div class="pull-right"> <?php echo get_phrase('amount');?> </div> </td> </tr> <tr> <td> <span style="font-size:20px;font-weight:100;"> <?php echo get_phrase('payment_made');?> </span> <br /> </td> <td width="30%" style="padding:5px;"> <div class="pull-right"> <span style="font-size:20px;font-weight:100;"> <?php echo "Gh", $row['amount'];?> </span> </div> </td> </tr> <tr> <tr> <td> <span style="font-size:20px;font-weight:100;"> <?php echo get_phrase('balance');?> </span> <br /> <?php echo $row['description'];?> <?php $exams = $this->db->get_where('fee_payment', array('student_id'=>$row['student_id']))->result_array(); foreach($exams as $row): ?> <?php $ttpaid = sum($row['amount']); echo $ttpaid;?> <?php endforeach; ?> </td> <td width="30%" style="padding:5px;"> <div class="pull-right"> <span style="font-size:20px;font-weight:100;"> <?php $tuition = $this->db->get_where('student' , array('student_id'=>$row['student_id']))->row()->tuition_fee; $status = $this->db->get_where('student' , array('student_id'=>$row['student_id']))->row()->status_fee; $total_fees = $tuition + $status; $balance_fee = $total_fees - $row['amount']; echo "Gh", $balance_fee; ?> </span> </div> </td> </tr> <tr> <td></td> <td width="30%" style="padding:5px;"> <div class="pull-right"> <hr /> <?php echo get_phrase('status');?> : <?php echo $row['status'];?> <br /> <?php echo get_phrase('receipt_no:');?> : <?php echo "FAVECSFP0000",$row['payment_id'];?> <br /> <?php echo get_phrase('date');?> : <?php echo date('m/d/Y', $row['creation_timestamp']);?> </div> </td> </tr> </table> <br /> <br /> <?php endforeach;?> </div> </div> output: ayment To fffff P O BOX 126 Credited Account: john Student Id : FAVECSID00006 Class : JHS2A Similar TutorialsI would like to create a script to check wether a user has made a payment to access a members only area of my site, much like a check-login script that checks if the user has logged in, i need it do do a similar check only its not looking to see if the user is logged in but if they have ever paid and if not; send them to the payments page before the access is granted... What section(s) if any, do i need to modify from this check-login script to change it to check for their payments? Code: [Select] <?php ob_start(); // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // Define $myusername and $mypassword $myusername=$_POST['myusername']; $mypassword=$_POST['mypassword']; // To protect MySQL injection (more detail about MySQL injection) $myusername = stripslashes($myusername); $mypassword = stripslashes($mypassword); $myusername = mysql_real_escape_string($myusername); $mypassword = mysql_real_escape_string($mypassword); $sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count==1){ // Register $myusername, $mypassword and redirect to file "login_success.php" session_register("myusername"); session_register("mypassword"); header("location:login_success.php"); } else { echo "Wrong Username or Password"; } ob_end_flush(); ?> Im creating a token system where if a user uploads notes they get tokens and can download other peoples notes. My problem is I am not sure where to store the information for who has bought the note for future download. Should I store the information in the database under the table that looks after the notes, in its own table, or in a file that has arrays of the Note names and the users who are allowed to download it. I figured the best way would to have it in the db table that looks after the users but im not sure how I would get about making it so that every time the user bought another note I didnt have to add a new field. I am developing paid property listing php website, I do not have al lot of scripting/database experience that is why I am farming this part of the work out. This website will provide a listing service which real estate agents can go to the site and look at the properties. They can search by Zip, city, or Sale by Owner. Alternatively, they can look at all the properties or recently posted. They will be able to see one tiny thumbnail with limited info like zip code/city. In order to see more pictures or get address info they will need to sign up and pay for each property to get more pics/info. So I need the script/scripts to do the following: 1. Provide all the search criteria as listed above (search by zip, search by city, Sale by Owner, Page that populates all the properties) 2. Provide a database interface so that I can upload the pics and enter new entries that will dynamically embed into my site. 3. Provide user access (new and existing) 4. Provide a shopping cart and payment gateway (Provide options for both Paypal and traditional Credit Card payment gateways) which will then allow the user access to the full info. 5. Must be able to integrate into my existing website/CSS If you are wondering if this will work, do not worry. My guy is taking the pics and getting the info has been getting business from real estate agents with this by word of mouth, it will work. Let me know ASAP as I am taking bids and looking to implement quickly. I can send a mock up by the man doing the property finding. Let me know what other info you need in order to get an accurate quote. best regards, Jordan McGehee I have a payment button for PayPal which securely stores the amount, but when the payment is made how do i know if it was paid or not so i can get the page to store this in the mysql database? I have a contact form with a file upload button, when you click on “submit” you are redirected on Paypal everything works fine but, I would like to send the contact form only when visitors have paid on Paypal. I’ve searched on google but I have not found a way to do this. Can anyone help? Cheers, Aidan. Hello,
I am not very good at javascript.
Actually i have form like this
<td> <input type="text" name="item[]" id="category" value="<?php echo $row1['item'];?>" /></td> <td> <input type="text" name="uom[]" class="span2" value="<?php echo $row1['uom'];?>" /></td> <td> <input type="text" name="description[]" value="<?php echo $row1['description'];?>" /></td> <td><input type="text" class="jQinv_item_qty span1" name="quantity[]" /></td> <td><input type="text" class="jQinv_item_unit span1" name="price[]" value="<?php echo $row1['selling_price'];?>" /></td> <td><select name="tax[]" class="jQinv_item_tax span1"> <option value="<?php echo $row1['tax'];?>"><?php echo $row1['tax'];?></option> <?php $l1 = mysql_query("select * from taxes") or die (mysql_error()); while($l2 = mysql_fetch_array($l1)) { ?> <option value="<?php echo $l2['rate']; ?>"> <?php echo $l2['name'];?> - <?php echo $l2['rate'];?>% </option> <?php } ?> </select></td> <td> <input type="text" class="jQinv_item_discount span1" name="discount[]" value="<?php echo $row1['discount'];?>" /></td> <td><input type="text" class="jQinv_item_frt span1" name="freight[]" placeholder="Freight" /></td> <td><input type="text" class="jQinv_item_frtax span1" name="freight_tax[]" placeholder="Frt Tax" /></td> <td><input type="text" class="jQinv_item_total span2" name="total[]" /></td> a =( ((Quantity * Price) - Discount) * (tax/100) ) + Freight + (Freight * (Freight tax/100))I tried doing like this, But it did not work at all function rowInputs() { var balance = 0; var subTotal = 0; var taxTotal = 0; $(".invE_table tr").not('.last_row').each(function () { var $unit_price = $('.jQinv_item_unit', this).val(); var $qty = $('.jQinv_item_qty', this).val(); var $tax = $('.jQinv_item_tax', this).val(); var $discount = $('.jQinv_item_discount', this).val(); var $frt = $('.jQinv_item_frt', this).val(); var $frtax = $('.jQinv_item_frtax', this).val(); var $total = (($unit_price * 1) * ($qty * 1))- $discount; var $tax_amount = (($total) *($tax/parseFloat("100"))); var $total_amount = (($tax_amount) + ($frt)) + $frtax; var parsedTotal = parseFloat( ('0' + $total_amount).replace(/[^0-9-\.]/g, ''), 10 ); var parsedTax = parseFloat( ('0' + $tax_amount).replace(/[^0-9-\.]/g, ''), 10 ); var parsedSubTotal = parseFloat( ('0' + $total).replace(/[^0-9-\.]/g, ''), 10 ); $('.jQinv_item_total',this).val(parsedTotal.toFixed(2)); subTotal += parsedSubTotal; taxTotal += parsedTax; balance += parsedTotal; }); var discount = parseFloat( ('0' + $('#inv_discount').val()).replace(/[^0-9-\.]/g, ''), 10 ); var balance_disc = balance - discount; $(".invE_subtotal span").html(subTotal.toFixed(2)); $(".invE_tax span").html(taxTotal.toFixed(2)); $(".invE_discount span").html(discount.toFixed(2)); $(".invE_balance span").html(balance_disc.toFixed(2)); } Hi All I am kinda new to php.... I disparately need help with php coding. I am entering in the website using student id. If student id does not exist in mysql database, it gives me error. That works fine. But If I try to echo StudentID on 2nd page, it is not displaying anything. Second problem is I want to display student first and last name using StudentID. But it is not displaying anything using StudentID. Why? I have been trying to solve it, but no success Following is the code for both problems - if(!$db_selected) { die("Can not use".DB_NAME.':'.mysql_err()); } @$Stud_ID = $_POST['Stud_ID']; ?> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <link rel="stylesheet" type="text/css" href="ACSDP.css" /> <title>Student Main Page</title> <head><h1>Welcome to Undergraduate Student Main Page</h1> </head> <body> <form name ="mainpage" method='POST'> <table> <tr> <td><label id="Stud_ID2" for="Stud_ID"> Student ID <?php echo "is:" ." ". @$Stud_ID; ?> </label></td> <td> <label id="degree">Degree: Computer Science</label></td> </tr> <tr> <td> <label id="name"> Student Name: <?php $query2 =mysql_query("SELECT Stud_Lastname, Stud_Firstname FROM Student WHERE Stud_ID='$Stud_ID'") or die('wrong query'.mysql_error()); while($row = mysql_fetch_array($query2)) { echo $row['Stud_Lastname'] . " " . $row['Stud_Firstname']; } If have made those statements bold. please help me...... This code works just fine to display a list of reservations for a given day and sums the guest and table counts just fine for the entire day. Sums all reservations returned.
What I am trying to do or figure out is a way to get totals based on specific time intervals. For example how many guests and tables at 8:00, 9:00, 10:00, etc....
I can see where the sums are calculated, but need help adding a way to add a variable to look at the reservation_time and sum by hour rather than just daily total.
$tablesum ++; $guestsum += $row->reservation_pax; <?php echo $guestsum;?> <?php echo _guest_summary;?>The full code that pulls in the data and then sums it up in total: <!-- Begin reservation table data --> <br/> <table class="global resv-table-small" cellpadding="0" cellspacing="0"> <tbody> <tr> <?php echo "<td class='noprint'> </td>"; echo "<td>Time</td>"; echo "<td>Guests/Type</td>"; echo "<td>Name</td>"; echo "<td>Special Instructions/Notes</td>"; echo "<td class='noprint'>Table</td>"; echo "<td class='noprint'>Status</td>"; echo "<td class='noprint'>Created</td>"; echo "<td class='noprint'>Details/Delete</td>"; echo "</tr>"; // Clear reservation variable $reservations =''; if ($_SESSION['page'] == 1) { $reservations = querySQL('all_reservations'); }else{ $reservations = querySQL('reservations'); } // reset total counters $tablesum = 0; $guestsum = 0; if ($reservations) { //start printing out reservation grid foreach($reservations as $row) { // reservation ID $id = $row->reservation_id; $_SESSION['reservation_guest_name'] = $row->reservation_guest_name; // check if reservation is tautologous $tautologous = querySQL('tautologous'); echo "<tr id='res-".$id."'>"; echo "<td"; // daylight coloring if ($row->reservation_time > $daylight_evening){ echo " class='evening noprint'"; }else if ($row->reservation_time > $daylight_noon){ echo " class='afternoon noprint'"; }else if ($row->reservation_time < $daylight_noon){ echo " class='morning noprint'"; } echo " style='width:10px !important; padding:0px;'> </td>"; echo "<td id='tb_time'"; // reservation after maitre message if ($row->reservation_timestamp > $maitre['maitre_timestamp'] && $maitre['maitre_comment_day']!='') { echo " class='tautologous' title='"._sentence_13."' "; } echo ">"; echo "<strong>".formatTime($row->reservation_time,$general['timeformat'])."</strong></td>"; echo "<td id='tb_pax'><strong class='big'>".$row->reservation_pax."</strong> <span class='noprint'>"; printType($row->reservation_hotelguest_yn); //echo "<img src='images/icons/user-silhouette.png' class='middle'/>"; echo "</span></td><td style='width:10%' id='tb_name'><span class='noprint'>".printTitle($row->reservation_title)."</span><strong> <a id='detlbuttontrigger' href='ajax/guest_detail.php?id=".$id."'"; // color guest name if tautologous if($tautologous>1){echo" class='tautologous tipsy' title='"._tautologous_booking."'";} echo ">".$row->reservation_guest_name."</a></strong>"; // old reservations symbol if( (strtotime($row->reservation_timestamp) + $general['old_days']*86400) <= time() ){ echo "<img src='images/icons/clock-bolt.png' class='help tipsyold middle smicon' title='"._sentence_11."' />"; } // recurring symbol if ($row->repeat_id !=0) { echo " <img src='images/icons/loop-alt.png' alt='"._recurring. "' title='"._recurring."' class='tipsy' border='0' >"; } echo"</td><td style='width:10%' id='tb_note'>"; if ($_SESSION['page'] == 1) { echo $row->outlet_name; }else{ echo $row->reservation_notes; } echo "</td>"; if($_SESSION['wait'] == 0){ echo "<td class='big tb_nr' style='width:85px;' id='tb_table'><img src='images/icons/table_II.png' class='tipsy leftside noprint' title='"._table."' /><div id='reservation_table-".$id."' class='inlineedit'>".$row->reservation_table."</div></td>"; } echo "<td class='noprint'><div>"; getStatusList($id, $row->reservation_status); echo "</div></td>"; echo "<td class='noprint'>"; echo "<small>".$row->reservation_booker_name." | ".humanize($row->reservation_timestamp)."</small>"; echo "</td>"; echo "<td class='noprint'>"; // MOVE BUTTON // echo "<a href=''><img src='images/icons/arrow.png' alt='move' class='help' title='"._move_reservation_to."'/></a>"; // WAITLIST ALLOW BUTTON if($_SESSION['wait'] == 1){ $leftspace = leftSpace(substr($row->reservation_time,0,5), $availability); if($leftspace >= $row->reservation_pax && $_SESSION['outlet_max_tables']-$tbl_availability[substr($row->reservation_time,0,5)] >= 1){ echo" <a href='#' name='".$id."' class='alwbtn'><img src='images/icons/check-alt.png' name='".$id."' alt='"._allow."' class='help' title='"._allow."'/></a> "; } } // EDIT/DETAIL BUTTON echo "<a href='?p=102&resID=".$id."'><img src='images/icons/pen-fill.png' alt='"._detail."' class='help' title='"._detail."'/></a> "; // DELETE BUTTON if ( current_user_can( 'Reservation-Delete' ) && $q!=3 ){ echo"<a href='#modalsecurity' name='".$row->repeat_id."' id='".$id."' class='delbtn'> <img src='images/icons/delete.png' alt='"._cancelled."' class='help' title='"._delete."'/></a>"; } echo"</td></tr>"; $tablesum ++; $guestsum += $row->reservation_pax; } } ?> </tbody> <tfoot> <tr style="border:1px #000;"> <td class=" noprint"></td><td></td> <td colspan="2" class="bold"><?php echo $guestsum;?> <?php echo _guest_summary;?></td> <td></td> <td colspan="2" class="bold"><?php echo $tablesum;?> <?php echo _tables_summary;?></td> <?php if($_SESSION['wait'] == 0){ //echo "<td></td>"; } ?> </tr> </tfoot> </table> <!-- End reservation table data --> Edited by mfandel, 26 October 2014 - 02:06 AM. Hello again, guys! I have a couple of questions that I hope anyone can answer. I am making a form that is storing the information in a database, and in this form I also want images to be uploaded. I want to make a function that allows the user to upload as many images as they would like to have in their ad on my website, and I also need something that can handle the upload process, and see how many images the user is trying to upload. Any easy solutions for this? I also have another question: As you can see on the example image underneath this text, I have a form with multiple inputs where the user is suppose to choose how many inputs they want to fill in themself. How should I store this information in the database, and how can I make a script that detects how many of the forms the user actually filled? I hope you guys understood what I was trying to say, and I thank you all anyways. Underneath you can see an image of my forms. Example image: Cheers, Marius Hey everyone, I'm pretty new to this, not my full time job, but just something I thought I'd give a shot... I have a database, in postgres, in which I make my query and I go fetch all the info I need. What I need to do next is the tricky part for me. For each line of results received, I have to output to a text file (.txt) but I have to respect a format that was given to me from the person requesting the info. Example: Character 1 must be G or N. Character 2 to to 11 will be a result from my database search, which is a 10 digit string. Character 12 to 14 must be spaces. Another rule is: start at character 78: input a value from my database search but it must not exceed 20 characters and if it is less then 20 character, fill the remaining with spaces. If anyways has a code I can copy and work off of I would really appreciate it....thanks! Hello I am very new to php and programming and I need a grand total of "$Total = odbc_result($result, "total");" but not sure of how to create it. Heres what i got... function printLB1 (){ $result = mysql_query("SELECT * FROM leaderboards ORDER BY CollegeFootballPoints DESC"); while ($row = mysql_fetch_object($result)) { $leaderboard[] = $row->Username; $leaderboardPoints[] = $row->CollegeFootballPoints; } $num = mysql_num_rows($reault); //I know from here to ................... needs to be in a var or echo or something. <tr> <td>1.</td> //This will auto increment too like i++ but i cna do that myself! <td>echo $leaderboard;</td> <td>echo $leaderboardPoints;</td> </tr> //Here......................................................... } I need to pull a table row per user. But i want to somehow do it once in a function and then ill echo the function into a table after the php stuff is done. Like i want to pull every a table row per user in the function. then display the function below that way i don't have to write a whole extra query and table row per person. If you understand please help if not please let me know where i can explain more. Thanks Hello all, thanks for everything you do! I used a php from generator to make the form seen on this page: http://www.firstpresgreenville.org/forms/retirementform/retirementform-alt.html I need to be able to click on the check boxes and get a dollar amount total in the total field....So if you checked "single", the total field would read $40, and if you checked on "couple", the field would read $50...simple as that... Is there anyway to make that happen? This is the code I am working with now.... <?php # This block must be placed at the very top of page. # -------------------------------------------------- require_once( dirname(__FILE__).'/form.lib.php' ); phpfmg_display_form(); # -------------------------------------------------- function phpfmg_form( $sErr = false ){ $style=" class='form_text' "; ?> <form name="frmFormMail" action='' method='post' enctype='multipart/form-data' onsubmit='return fmgHandler.onsubmit();'> <input type='hidden' name='formmail_submit' value='Y'> <div id='err_required' class="form_error" style='display:none;'> <label class='form_error_title'>Please check the required fields</label> </div> <ol class='phpfmg_form' > <li class='field_block' id='field_0_div'><div class='col_label'> <label class='form_field'>Full Name(s)</label> <label class='form_required' >*</label> </div> <div class='col_field'> <input type="text" name="field_0" id="field_0" value="<?php phpfmg_hsc("field_0"); ?>" class='text_box'> <div id='field_0_tip' class='instruction'></div> </div> </li> <li class='field_block' id='field_1_div'><div class='col_label'> <label class='form_field'>Street Address</label> <label class='form_required' >*</label> </div> <div class='col_field'> <input type="text" name="field_1" id="field_1" value="<?php phpfmg_hsc("field_1"); ?>" class='text_box'> <div id='field_1_tip' class='instruction'></div> </div> </li> <li class='field_block' id='field_2_div'><div class='col_label'> <label class='form_field'>City</label> <label class='form_required' >*</label> </div> <div class='col_field'> <input type="text" name="field_2" id="field_2" value="<?php phpfmg_hsc("field_2"); ?>" class='text_box'> <div id='field_2_tip' class='instruction'></div> </div> </li> <li class='field_block' id='field_3_div'><div class='col_label'> <label class='form_field'>State</label> <label class='form_required' >*</label> </div> <div class='col_field'> <input type="text" name="field_3" id="field_3" value="<?php phpfmg_hsc("field_3"); ?>" class='text_box'> <div id='field_3_tip' class='instruction'></div> </div> </li> <li class='field_block' id='field_4_div'><div class='col_label'> <label class='form_field'>Zip Code</label> <label class='form_required' >*</label> </div> <div class='col_field'> <input type="text" name="field_4" id="field_4" value="<?php phpfmg_hsc("field_4"); ?>" class='text_box'> <div id='field_4_tip' class='instruction'></div> </div> </li> <li class='field_block' id='field_5_div'><div class='col_label'> <label class='form_field'>Phone</label> <label class='form_required' >*</label> </div> <div class='col_field'> <input type="text" name="field_5" id="field_5" value="<?php phpfmg_hsc("field_5"); ?>" class='text_box'> <div id='field_5_tip' class='instruction'>(###) ###-####</div> </div> </li> <li class='field_block' id='field_6_div'><div class='col_label'> <label class='form_field'>Email</label> <label class='form_required' >*</label> </div> <div class='col_field'> <input type="text" name="field_6" id="field_6" value="<?php phpfmg_hsc("field_6"); ?>" class='text_box'> <div id='field_6_tip' class='instruction'></div> </div> </li> <li class='field_block' id='field_7_div'><div class='col_label'> <label class='form_field'>Number of Attendees</label> <label class='form_required' >*</label> </div> <div class='col_field'> <input type="text" name="field_7" id="field_7" value="<?php phpfmg_hsc("field_7"); ?>" class='text_box'> <div id='field_7_tip' class='instruction'></div> </div> </li> <li class='field_block' id='field_8_div'><div class='col_label'> <label class='form_field'>Single or Couple?</label> <label class='form_required' >*</label> </div> <div class='col_field'> <?php phpfmg_checkboxes( 'field_8', "Single|Couple" );?> <div id='field_8_tip' class='instruction'></div> </div> </li> <li class='field_block' id='field_9_div'><div class='col_label'> <label class='form_field'>Amount Due</label> <label class='form_required' >*</label> </div> <div class='col_field'> <input type="text" name="field_9" id="field_9" value="<?php phpfmg_hsc("field_9"); ?>" class='text_box'> <div id='field_9_tip' class='instruction'>$40/ single or $50/couple (Includes one book and lunch)</div> </div> </li> <li class='field_block' id='field_10_div'><div class='col_label'> <label class='form_field'>Additional Comments</label> <label class='form_required' > </label> </div> <div class='col_field'> <textarea name="field_10" id="field_10" rows=4 cols=25 class='text_area'><?php phpfmg_hsc("field_10"); ?></textarea> <div id='field_10_tip' class='instruction'></div> </div> </li> <?php phpfmg_dependent_dropdown( 'field_11' );?> <li> <div class='col_label'> </div> <div class='form_submit_block col_field'> <input type='submit' value='Submit' class='form_button'> <span id='phpfmg_processing' style='display:none;'> <img id='phpfmg_processing_gif' src='<?php echo PHPFMG_ADMIN_URL . '?mod=image&func=processing' ;?>' border=0 alt='Processing...'> <label id='phpfmg_processing_dots'></label> </span> </div> </li> </ol> </form> <?php phpfmg_javascript($sErr); } # end of form function phpfmg_form_css(){ ?> Thanks so much! <html> <head> <title>Sum Html Textbox Values using jQuery/JavaScript</title> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> <script> $(function() { $(document).on('blur keyup', '.add, .sub', function(e) { var sum = 0; $('.add, .sub').each(function(i) { if (!isNaN(this.value) && this.value.length != 0) { if ($(this).hasClass('add')) { sum += parseFloat(this.value); } else { sum -= parseFloat(this.value); } } }); $('#total').text(sum.toFixed(2)); }) }) </script> </head> <body> <form method="post" action="calc.php"> Addition: <br/> Field 1: <input type="text" class="add" name="1" value="7500"/><br/> Field 2: <input type="text" class="add" name="2" value=""/><br/> Field 3: <input type="text" class="add" name="3" value=""/><br/> Field 4: <input type="text" class="add" name="4" value=""/><br/><br/> Total Addition: <br/><br/> Substraction: <br/> Field 1: <input type="text" class="sub" name="5" value=""/><br/> Field 2: <input type="text" class="sub" name="6" value=""/><br/> Field 3: <input type="text" class="sub" name="7" value=""/><br/> Field 4: <input type="text" class="sub" name="8" value=""/><br/><br/> Total Substraction: <br/><br/> Grand Total: <div id="total"></div> <input type="submit" value="submit" /> </form> </body> </html> Hi I get the following error when running this file. Fatal error: Call to undefined function mysqql_query() in C:\wamp\www\Isis\login.php on line 14] I'm not sure if i have missed something or typed something wrong but a second opinion is always better <?php $username = $_POST['username']; $password = $_POST['password']; $login = $_GET['login']; setcookie("username", "$username", time()+86400); if ($login=='yes') { $con = mysql_connect("localhost","root",""); mysql_select_db("obsosuser"); $get = mysqql_query("SELECT count(id) FROM obsosuser WHERE username='$username' and password='$password'"); if ($result!=1){ echo "Invalid Login!"; } else echo "Login Successful! Welcome back ".$_COOKIE['username']." Sir/Maddam." ; $_SESSION ['username'] = $username; } ?> Thanks 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. I have a problem with login issue that when i loggin as student from index.php it should bring me to student_home php.. but it doesnt show anything and just bring me to index.php back.. i mixed up about header and session part..
index.php
<?php include('header.php'); //Start session session_start(); //Unset the variables stored in session unset($_SESSION['id']); ?> <body> <?php include('navhead.php'); ?> <div class="container"> <div class="row-fluid"> <div class="span3"> <div class="hero-unit-3"> <div class="alert-index alert-success"> <i class="icon-calendar icon-large"></i> <?php $Today = date('y:m:d'); $new = date('l, F d, Y', strtotime($Today)); echo $new; ?> </div> </div> <div class="hero-unit-1"> <ul class="nav nav-pills nav-stacked"> <li class="nav-header">Links</li> <li class="active"><a href="#"><i class="icon-home icon-large"></i> Home <div class="pull-right"> <i class="icon-double-angle-right icon-large"></i> </div> </a></li> <li><a href="sitemap.php"><i class="icon-sitemap icon-large"></i> Site Map <div class="pull-right"> <i class="icon-double-angle-right icon-large"></i> </div> </a></li> <li><a href="contact.php"><i class="icon-envelope-alt icon-large"></i> Contact Us <div class="pull-right"> <i class="icon-double-angle-right icon-large"></i> </div> </a> </li> <li class="nav-header">About US</li> <li><a href="#mission" role="button" data-toggle="modal"><i class="icon-book icon-large"></i> Mission <div class="pull-right"> <i class="icon-double-angle-right icon-large"></i> </div> </a></li> <li><a href="#vision" role="button" data-toggle="modal"><i class="icon-book icon-large"></i> Vision <div class="pull-right"> <i class="icon-double-angle-right icon-large"></i> </div> </a></li> <li><a href="history.php"><i class="icon-list-alt icon-large"></i> History <div class="pull-right"> <i class="icon-double-angle-right icon-large"></i> </div> </a></li> </ul> </div> <br> </div> <div class="span9"> <section class="main"> <div class="custom-calendar-wrap"> <div id="custom-inner" class="custom-inner"> <div class="custom-header clearfix"> <nav> <span id="custom-prev" class="custom-prev"></span> <span id="custom-next" class="custom-next"></span> </nav> <h2 id="custom-month" class="custom-month"></h2> <h3 id="custom-year" class="custom-year"></h3> </div> <div id="calendar" class="fc-calendar-container"></div> </div> </div> </section> <div class="alert alert-info"> <button type="button" class="close" data-dismiss="alert">×</button> <strong>Head Up!</strong> Welcome to Morpheus. </div> <div class="slider-wrapper theme-default"> <?php include('slider.php'); ?> </div> <!-- end slider --> </div> </div> </div> <!----------------> <div class="container"> <div class="row-fluid"> <div class="span12"> <div class="row-fluid"> <div class="span9"> <div class="alert alert-success"><i class="icon-file icon-large"></i> <strong>Mission</strong></div> <div class="hero-unit-2"> Announcements </div> </div> <div class="span3"> <div class="alert alert-info"> <i class="icon-building icon-large"></i> Faculty </div> <div class="hero-unit-3"> <p><a href=""><i class="icon-sign-blank"></i> Faculty</a></p> <p><a href=""><i class="icon-sign-blank"></i> Faculty</a></p> <p><a href=""><i class="icon-sign-blank"></i> Faculty</a></p> <p><a href=""><i class="icon-sign-blank"></i> Faculty</a></p> </div> </div> </div> </div> </div> <br> <div class="alert alert-success"><i class="icon-file icon-large"></i> <strong>Project</strong></div> <div class="hero-unit-2"> Project </div> <?php include('footer.php'); ?> </div> </body> </html>navhead.php <div class="row-fluid"> <div class="span12"> <div class="navbar navbar-fixed-top navbar-inverse"> <div class="navbar-inner"> <div class="container"> <a class="btn btn-navbar" data-toggle="collapse" data-targer=".nav-collapse"> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </a> <div class="nav-collapse collapse"> <i class="icon-facebook-sign icon-large" id="color_white"></i> <i class="icon-twitter icon-large" id="color_white"></i> <i class="icon-google-plus icon-large" id="color_white"></i> <i class="icon-github-alt icon-large" id="color_white"></i> <i class="icon-linkedin-sign icon-large" id="color_white"></i> <div class="pull-right"> <form class="navbar-search pull-left"> <i class="icon-search icon-large" id="color_white"></i> <input type="text" class="search-query" placeholder="Search"> </form> </div> </div> </div> </div> </div> </div> </div> <div class="hero-unit-header"> <div class="container"> <div class="row-fluid"> <div class="span12"> <div class="row-fluid"> <div class="span6"> <img src="admin/images/head.png"> </div> <div class="span6"> <div class="pull-right"> <!--- login button --> <div class="btn-group"> <button class="btn btn-success"><i class="icon-signin icon-large"></i> Login</button> <button class="btn dropdown-toggle" data-toggle="dropdown"> <span class="caret"></span> </button> <ul class="dropdown-menu"> <li><a href="#student" role="button" data-toggle="modal"><i class="icon-user icon-large"></i> Student</a></li> <li><a href="#teacher" role="button" data-toggle="modal"><i class="icon-user-md icon-large"></i> Teacher</a></li> </ul> </div> <!-- end login --> <?php include('student_modal.php'); ?> <?php include('teacher_modal.php'); ?> </div> </div> </div> </div> </div> </div> </div>student_modal.php <div id="student" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal-header"> </div> <div class="modal-body"> <div class="alert alert-info"> <button type="button" class="close" data-dismiss="alert">×</button> <strong>Login Student!</strong> Please Enter the Details Below. </div> <form class="form-horizontal" method="post"> <div class="control-group"> <label class="control-label" for="inputEmail">Username</label> <div class="controls"> <input type="text" name="username" id="inputEmail" placeholder="Username"> </div> </div> <div class="control-group"> <label class="control-label" for="inputPassword">Password</label> <div class="controls"> <input type="password" name="password" id="inputPassword" placeholder="Password"> </div> </div> <div class="control-group"> <div class="controls"> <button type="submit" name="login" class="btn btn-info"><i class="icon-signin icon-large"></i> Sign in</button> </div> </div> <?php if (isset($_POST['login'])) { function clean($str) { $str = @trim($str); if (get_magic_quotes_gpc()) { $str = stripslashes($str); } return mysql_real_escape_string($str); } $username = clean($_POST['username']); $password = clean($_POST['password']); $query = mysql_query("select * from student where username='$username' and password='$password'") or die(mysql_error()); $count = mysql_num_rows($query); $row = mysql_fetch_array($query); if ($count > 0) { session_start(); session_regenerate_id(); $_SESSION['id'] = $row['student_id']; header('location:student_home.php'); session_write_close(); exit(); } else { header('error_login.php'); ?> <?php } } ?> </form> <!-- teacher --> </div> <div class="modal-footer"> <button class="btn" data-dismiss="modal" aria-hidden="true"><i class="icon-remove-sign icon-large"></i> Close</button> </div> </div> login_student.php [php]<?php include('header.php'); //Start session session_start(); //Unset the variables stored in session unset($_SESSION['id']); ?> <body> <?php include('navhead.php'); ?> <div class="container"> <div class="row-fluid"> <div class="span10"> <ul class="breadcrumb"> <li class="active">Login<span class="divider">/</span></li> <li><a href="login_student.php"><i class="icon-group icon-large"></i> Teacher</a><span class="divider">/</span></li> <li class="active"><i class="icon-group icon-large"></i> Student</li> <div class="pull-right"> <li> <i class="icon-calendar icon-large"></i> <?php $Today = date('y:m:d'); $new = date('l, F d, Y', strtotime($Today)); echo $new; ?> </li> </div> </ul> <div class="alert alert-info"> <button type="button" class="close" data-dismiss="alert">×</button> <strong>Login Student!</strong> Please Enter the Details Below. </div> <form class="form-horizontal" method="post"> <div class="control-group"> <label class="control-label" for="inputEmail">Username</label> <div class="controls"> <input type="text" name="username" id="inputEmail" placeholder="Username"> </div> </div> <div class="control-group"> <label class="control-label" for="inputPassword">Password</label> <div class="controls"> <input type="password" name="password" id="inputPassword" placeholder="Password"> </div> </div> <div class="control-group"> <div class="controls"> <button type="submit" name="login" class="btn btn-info"><i class="icon-signin"></i> Sign in</button> </div> </div> <?php if (isset($_POST['login'])) { function clean($str) { $str = @trim($str); if (get_magic_quotes_gpc()) { $str = stripslashes($str); } return mysql_real_escape_string($str); } $username = clean($_POST['username']); $password = clean($_POST['password']); $query = mysql_query("select * from user where username='$username' and password='$password'") or die(mysql_error()); $count = mysql_num_rows($query); $row = mysql_fetch_array($query); if ($count > 0) { session_start(); session_regenerate_id(); $_SESSION['id'] = $row['user_id']; header('location:student_home.php'); session_write_close(); exit(); } else { session_write_close(); ?> <div class="pull-right"> <button type="button" class="close" data-dismiss="alert">×</button> <div class="alert alert-danger"><i class="icon-remove-sign"></i> Access Denied</div> </div> <?php exit(); } } ?> </form> </div> <div class="span2"> <div class="hero-unit-1"> <ul class="nav nav-pills nav-stacked"> <li class="nav-header">Links</li> <li><a href="index.php"><i class="icon-home icon-large"></i> Home</a></li> <li><a href="#"><i class="icon-file-alt icon-large"></i> New And Events</a></li> <li><a href="#"><i class="icon-sitemap icon-large"></i> Site Map</a></li> <li><a href="#"><i class="icon-envelope-alt icon-large"></i> Contact Us</a></li> <li class="nav-header">About US</li> <li><a href="#"><i class="icon-book icon-large"></i> Mission</a></li> <li><a href="#"><i class="icon-book icon-large"></i> Vision</a></li> <li><a href="#"><i class="icon-list-alt icon-large"></i> History</a></li> </ul> </div> </div> </div> <?php include('footer.php'); ?> </div> </body> </html>login_student.php <?php include('header.php'); //Start session session_start(); //Unset the variables stored in session unset($_SESSION['id']); ?> <body> <?php include('navhead.php'); ?> <div class="container"> <div class="row-fluid"> <div class="span10"> <ul class="breadcrumb"> <li class="active">Login<span class="divider">/</span></li> <li><a href="login_student.php"><i class="icon-group icon-large"></i> Teacher</a><span class="divider">/</span></li> <li class="active"><i class="icon-group icon-large"></i> Student</li> <div class="pull-right"> <li> <i class="icon-calendar icon-large"></i> <?php $Today = date('y:m:d'); $new = date('l, F d, Y', strtotime($Today)); echo $new; ?> </li> </div> </ul> <div class="alert alert-info"> <button type="button" class="close" data-dismiss="alert">×</button> <strong>Login Student!</strong> Please Enter the Details Below. </div> <form class="form-horizontal" method="post"> <div class="control-group"> <label class="control-label" for="inputEmail">Username</label> <div class="controls"> <input type="text" name="username" id="inputEmail" placeholder="Username"> </div> </div> <div class="control-group"> <label class="control-label" for="inputPassword">Password</label> <div class="controls"> <input type="password" name="password" id="inputPassword" placeholder="Password"> </div> </div> <div class="control-group"> <div class="controls"> <button type="submit" name="login" class="btn btn-info"><i class="icon-signin"></i> Sign in</button> </div> </div> <?php if (isset($_POST['login'])) { function clean($str) { $str = @trim($str); if (get_magic_quotes_gpc()) { $str = stripslashes($str); } return mysql_real_escape_string($str); } $username = clean($_POST['username']); $password = clean($_POST['password']); $query = mysql_query("select * from user where username='$username' and password='$password'") or die(mysql_error()); $count = mysql_num_rows($query); $row = mysql_fetch_array($query); if ($count > 0) { session_start(); session_regenerate_id(); $_SESSION['id'] = $row['user_id']; header('location:student_home.php'); session_write_close(); exit(); } else { session_write_close(); ?> <div class="pull-right"> <button type="button" class="close" data-dismiss="alert">×</button> <div class="alert alert-danger"><i class="icon-remove-sign"></i> Access Denied</div> </div> <?php exit(); } } ?> </form> </div> <div class="span2"> <div class="hero-unit-1"> <ul class="nav nav-pills nav-stacked"> <li class="nav-header">Links</li> <li><a href="index.php"><i class="icon-home icon-large"></i> Home</a></li> <li><a href="#"><i class="icon-file-alt icon-large"></i> New And Events</a></li> <li><a href="#"><i class="icon-sitemap icon-large"></i> Site Map</a></li> <li><a href="#"><i class="icon-envelope-alt icon-large"></i> Contact Us</a></li> <li class="nav-header">About US</li> <li><a href="#"><i class="icon-book icon-large"></i> Mission</a></li> <li><a href="#"><i class="icon-book icon-large"></i> Vision</a></li> <li><a href="#"><i class="icon-list-alt icon-large"></i> History</a></li> </ul> </div> </div> </div> <?php include('footer.php'); ?> </div> </body> </html> Hi All
I am having problems running a query to get the courses a student is enrolled for.
The format I need is somthing like this:
firstname - lastname - course ------------------------------------------- Joe Bloke US232456 Joe Bloke US554665 Joe Bloke US332098or like this firstname - lastname - course ------------------------------------------------- Joe Bloke US232456 US554665 US332098The query I am running is SELECT usr.firstname, usr.lastname, c.shortname FROM mdl_course c INNER JOIN mdl_context cx ON c.id = cx.instanceid AND cx.contextlevel = '50' INNER JOIN mdl_role_assignments ra ON cx.id = ra.contextid INNER JOIN mdl_role r ON ra.roleid = r.id INNER JOIN mdl_user usr ON ra.userid = usr.id WHERE r.name = 'Learner' AND usr.firstname = 'G01 Moloko' ORDER BY usr.firstname, c.shortnameThe problem is that I know this student is enrolled for 3 courses, but it only returns 1 course. Any help is welcomed. huck I use the Wholesale Suite Premium Prices plugin with WooCommerce. I have 6 specific wholesale roles out of 15 that I wish to hide two specific shipping methods from being selected for the 6 exceptions. I'm just trying this on my staging server at this time using a code snippet example that I found and modified for my specific conditions. Would the following work for this purpose? /* Hide specific shipping methods for specific wholesale roles */ add_filter( 'woocommerce_package_rates', function( $shipping_rates ) { // User role and shipping method ID to hide for the user role $role_shipping_method_arr = array( 'ws_silvia_silver' => array( 'Silvia Premium Standard Shipping (Tracking Service)'), 'ws_silvia_silver_pst_exempt' => array( 'Silvia Premium Standard Shipping (Tracking Service)'), 'ws_silvia_silver_tax_exempt' => array( 'Silvia Premium Standard Shipping (Tracking Service)'), 'ws_silvia_silver' => array( 'Silvia Union Standard Shipping (Tracking Service)'), 'ws_silvia_silver_pst_exempt' => array( 'Silvia Union Standard Shipping (Tracking Service)'), 'ws_silvia_silver_tax_exempt' => array( 'Silvia Union Standard Shipping (Tracking Service)'), 'ws_silvia_gold' => array( 'Silvia Premium Standard Shipping (Tracking Service)'), 'ws_silvia_gold_pst_exempt' => array( 'Silvia Premium Standard Shipping (Tracking Service)'), 'ws_silvia_gold_tax_exempt' => array( 'Silvia Premium Standard Shipping (Tracking Service)'), 'ws_silvia_gold' => array( 'Silvia Union Standard Shipping (Tracking Service)'), 'ws_silvia_gold_pst_exempt' => array( 'Silvia Union Standard Shipping (Tracking Service)'), 'ws_silvia_gold_tax_exempt' => array( 'Silvia Union Standard Shipping (Tracking Service)'), ); // Getting the current user role $curr_user = wp_get_current_user(); $curr_user_data = get_userdata($current_user->ID); // Wholesale Suite Roles if (isset($current_user) && class_exists('WWP_Wholesale_Roles')) { $wwp_wholesale_roles = WWP_Wholesale_Roles::getInstance(); $wwp_wholesale_role = $wwp_wholesale_roles->getUserWholesaleRole(); // Loop through the user role and shipping method pair foreach( $role_shipping_method_arr as $role => $shipping_methods_to_hide ) { // Check if defined role exist in current user role or not if( in_array( $role, $current_user->roles) ) { // Loop through all the shipping rates foreach( $shipping_rates as $shipping_method_key => $shipping_method ) { $shipping_id = $shipping_method->get_id(); // Unset the shipping method if found if( in_array( $shipping_id, $shipping_methods_to_hide) ) { unset($shipping_rates[$shipping_method_key]); } } } } } return $shipping_rates; }); Any insights as to how to accomplish this would be greatly appreciated. Lyse Hello sir, My name is Soji. I'm working on a php project on result transcript processing. I got to a stage where i need to rank student based on their score (Subject Position) and also Overall Position. I have tried all i could but i still don't get it I have a table called Subject position where with field (id, studentregNo, subjectid, levelid, armsid, yearid, total). what i want is if there is 3 student in a class and the first student score 50 in english and the second student score 45 and the third score 40. i want the system to tell me that the first student position in English is 1st and the second student position in English is 2nd and third student position in English is 3rd. So all this will be applicable to all subjects that the students in a particular level are offering.
Moreover, I need Rank student in a subject in that class, And this will work with each subject for each student in that class. |