Jump to content

eloginko

New Members
  • Posts

    9
  • Joined

  • Last visited

eloginko's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. As you can see there is a value already on the (total)textbox which i filtered on a table...and if i type a number on the (score)textboxes it will automatically add on the current value of the total(textbox). My problem is its not adding perfectly. example: http://s38.photobucket.com/user/eloginko/media/score_zps43f9daaa.jpg.html html code: <form id="frm" name="frm" /> <table> <tr> <td> Name: <br /> <input type="text" name="name" value="<?php if(empty($name[0])){$name[0] = array(NULL);}else{echo $name[0];} ?>" readonly /> <br /> </td> <td> Score 1: <br /> <input type="text" name="optA" value="" onchange="optTotal()" /> <br /> </td> <td> Score 2: <br /> <input type="text" name="optB" value="" onchange="optTotal()" /> <br /> </td> <td> Score 3: <br /> <input type="text" name="optC" value="" onchange="optTotal()" /> <br /> </td> <td> Score 4: <br /> <input type="text" name="optD" value="" onchange="optTotal()" /> <br /> </td> <td> Total: <br /> <input type="text" name="totals" value="<?php if(empty($total[0])){$total[0] = array(NULL);}else{echo $total[0];} ?>" readonly onKeyUp="optTotal()" /> <br /> </td> </form> total calculation script: <script> function optTotal() { var a1 = document.forms[0].optA; var b1 = document.forms[0].optB; var c1 = document.forms[0].optC; var d1 = document.forms[0].optD; var xtotal = document.forms[0].totals; if (a1.value && a1.value != "") a1 = parseFloat(a1.value); else a1 = 0; if (b1.value && b1.value != "") b1 = parseFloat(b1.value); else b1 = 0; if (c1.value && c1.value != "") c1 = parseFloat(c1.value); else c1 = 0; if (d1.value && d1.value != "") d1 = parseFloat(d1.value); else d1 = 0; if (xtotal.value && xtotal.value != "") xtotal = parseFloat(xtotal.value); else xtotal = 0; var total = a1 + b1 + c1 + d1 + xtotal; document.forms[0].totals.value = total; } </script>
  2. How to filter and show data in search without using submit button..because thats the only function i need to finish my code..can anyone help me? I dont want to use submit button cause it refreshes the page...I have the code for search already I need a function that after I search the data will show in the textboxes without using submit button. php code: <?php if($_GET){ include('include/connect.php'); $batchcode = $_GET['code']; $sql = mysql_query("SELECT aic,batchcode,address,name FROM tb_app WHERE batchcode = '".$batchcode."' "); if($sql) { while($rows = mysql_fetch_array($sql)){ $aic[] = $rows['aic']; $name[] = $rows['name']; $address[] = $rows['address']; } } }else{ $aic = array(NULL,NULL,NULL,NULL); $name = array(NULL,NULL,NULL,NULL); $address = array(NULL,NULL,NULL,NULL); } ?> html code: <html> <head> <title>test</title> </head> <body> <form action="" method="get"> Search Batchcode:<input type="text" name="code" id="query" /><br /> <table> <tr> <td> aic: <br /> <input type="text" name="optA1" value="<?php if(empty($aic[0])){$aic[0] = array(NULL);}else{echo $aic[0];} ?>" /> <br /> <input type="text" name="optA2" value="<?php if(empty($aic[1])){$aic[1] = array(NULL);}else{echo $aic[1];} ?>" /> <br /> <input type="text" name="optA3" value="<?php if(empty($aic[2])){$aic[2] = array(NULL);}else{echo $aic[2];} ?>" /> <br /> <input type="text" name="optA4" value="<?php if(empty($aic[3])){$aic[3] = array(NULL);}else{echo $aic[3];} ?>" /> <br /> </td> <td> Name List: <br /> <input type="text" name="optB1" value="<?php if(empty($name[0])){$name[0] = array(NULL);}else{echo $name[0];} ?>" /> <br /> <input type="text" name="optB2" value="<?php if(empty($name[1])){$name[1] = array(NULL);}else{echo $name[1];} ?>" /> <br /> <input type="text" name="optB3" value="<?php if(empty($name[2])){$name[2] = array(NULL);}else{echo $name[2];} ?>" /> <br /> <input type="text" name="optB4" value="<?php if(empty($name[3])){$name[3] = array(NULL);}else{echo $name[3];} ?>" /> <br /> </td> <td> Address: <br /> <input type="text" name="optC1" value="<?php if(empty($address[0])){$address[0] = array(NULL);}else{echo $address[0];} ?>" /> <br /> <input type="text" name="optC2" value="<?php if(empty($address[1])){$address[1] = array(NULL);}else{echo $address[1];} ?>" /> <br /> <input type="text" name="optC3" value="<?php if(empty($address[2])){$address[2] = array(NULL);}else{echo $address[2];} ?>" /> <br /> <input type="text" name="optC4" value="<?php if(empty($address[3])){$address[3] = array(NULL);}else{echo $address[3];} ?>" /> <br /> </td> </form> </body> </html> script code: <!--search function code--> <script type="text/javascript"> $(document).ready(function(){ $("#query").autocomplete({ source : 'search.php', select : function(event,ui){ $("#query").html(ui.item.value); } }); }); </script> search.php page code: <?php $q = $_GET['term']; mysql_connect("localhost","root",""); mysql_select_db("test"); $query = mysql_query("SELECT DISTINCT batchcode FROM tb_app WHERE batchcode LIKE '$q%'"); $data = array(); while($row = mysql_fetch_array($query)){ $data[]=array('value'=>$row['batchcode']); } echo json_encode($data); ?>
  3. how to make a stored procedure in sql and use it on php?? i wanna make a stored procedure of my queries below and use it on my php program. can anyone help me? Please //query 1 INSERT INTO afnup_worksheet (faic,fnl_name,ftotal) SELECT DISTINCT atic ,atname ,(SELECT SUM(inttotal) FROM app_interview t2 WHERE t2.atic = t.atic)/7 FROM app_interview t GROUP BY atname HAVING COUNT(DISTINCT atic) //query 2 SELECT count(t.atic) as total,t2.name FROM app_interview as t, tb_applicants as t2 WHERE t.atic = t2.aic GROUP BY t.atic;
  4. can anyone help me come up a good php condition that if a specific aic from tb_applicants with a total=7 from this query SELECT count(t.atic) as total,t2.name FROM app_interview as t, tb_applicants as t2 WHERE t.atic = t2.aic GROUP BY t.atic; will execute this query INSERT INTO afnup_worksheet (faid,faic,fnl_name,ftotal) SELECT DISTINCT t.atid ,t.atic ,t.atname ,(SELECT SUM(t2.inttotal) FROM app_interview t2 WHERE t2.atic = t.atic)/7 thissum FROM app_interview t GROUP BY atname HAVING COUNT(DISTINCT atic)=1 i want to execute insert query to those specific applicants if those applicants with a total of 7 on the count query matches..can anyone help me?please im still learning..so be easy on me
  5. I have a table called tb_applicants with fields 'id','aic','name','total' This query total all the total of applicant with same aic field value and divide it with 7 and save the average score to a new table called: fapptotal with field 'id','aic','name','ftotal' My problem is i have the mysql query for it but i dont know how to use it in php..can anyone help me convert my query to php query. here is my query: INSERT INTO fapptotal (id,aic,name,ftotal) SELECT DISTINCT t.id ,t.aic ,t.name ,(SELECT SUM(t2.total) FROM tb_applicants t2 WHERE t2.aic = t.aic)/7 thissum FROM tb_applicants t GROUP BY name HAVING COUNT(DISTINCT aic)=1
  6. @Ch0cu3r i forgot to put the url it worked now thx
  7. @Ch0cu3r it only show 0001,1 in the aic and batchcode textbox even its not? i try to change the value in the database but it shows '0001' and '1' all the time?
  8. @Ch0cu3r the code you present doesn't work?? did you try it?
  9. I have a table called tb_app with fields 'id','aic','batchcode','name' example table value: '1','0001','1','james'. As you can see there are three textboxes(name)(aic)(batchode). I want to show the value of aic and batchcode in their correspoding textboxes after typing the specific name in the textbox(name). The problem is when you type james in the textbox(name) it shows '00011' in the (aic)textbox and (batchcode)textbox...i want it to be '0001' in aic and '1' in the batchcode if i type james which is stored value in the table. html code: <form method="post"> <input type="text" name="names" id="query" onblur="getvalues()"/> <input type="text" name="aic" id="aic"/> <input type="text" name="batchcode" id="batchcode" /> </form> script code: <script type="text/javascript"> function getvalues() { var selname = $("input[name=names]:text").val(); $.ajax({ url: "getuserdata.php", data: {"selname":selname}, type: 'post', success: function(output) { $("#aic").val(output); $("#batchcode").val(output); } }); } </script> getuserdata.php page: <?php include('include/connect.php'); $selname = $_POST['selname']; $query = "SELECT * FROM tb_app WHERE tb_app.name RLIKE '$selname'"; $result = mysql_query($query) or die(mysql_error()); while($rows = mysql_fetch_array($result)){ echo $rows['aic']; echo $rows['batchcode']; } ?>
×
×
  • 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.