Jump to content

iammudassir

Members
  • Posts

    23
  • Joined

  • Last visited

Everything posted by iammudassir

  1. i change my line like thisdocument.getElementById("txtHint").value=xmlhttp.responseText; '''''' here you can see i change innerHTML to Value , now it showing result in my INPUT field but like this <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Untitled Document</title></head><body><td>real</td></body></html> my result is only one word "REAL" but it shows above three lines in my input Field , please please correct my code i dont know JAVA and AJAx
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Untitled Document</title></head> <body><html><head><script>function showUser(str){if (str=="") { document.getElementById("txtHint").value=""; return; } if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); }else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); }xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("txtHint").innerHTML=xmlhttp.responseText; } }xmlhttp.open("GET","getuser.php?q="+str,true);xmlhttp.send();}</script></head><body> <form><select name="users" onchange="showUser(this.value)"><option value="">Select a person:</option><option value="1">1</option><option value="2">2</option></select><input name="buyername" type="text" id="txtHint" /> """" I WANT TO DISPLAY RESULT IN THIS FIELD"""" </form><br><div id="txtHint"><b>Person info will be listed here.</b></div> RESULT IS DISPLAYING HERE </body></html></body></html> QUESTION:I WANT TO DISPLAY RESULT IN MY INPUT FIELD<input name="buyername" type="text" id="txtHint" />AS YOU KNOW RESULT COMES FROMdocument.getElementById("txtHint").innerHTML=xmlhttp.responseText;
  3. i think a solution when my query run it save values ('$myname' , '$mydate' ) here $mydate save as '' means (empty) and empty data save as 0000-00-00my solution is after this query i will run another query of update like thisupdate mytable set mydate = NULL where mydate = "0000-00-00" ;or give me another solution so save NULL in date field in database though PHP vairable
  4. after trying these both solution now mydatabase shows "0000-00-00" now i understand what my problem issee this$myname = "abc"$mydate = NULL or $mydate = 'NULL' (i try these both style) here $mydate is NULL but problem start when i run my sql query $query = "INSERT INTO mytable (myname , mydate ) values ('$myname' , '$mydate' )";$mydate = NULL but in query it is uner ' ' so NULL save as 'NULL' and date cannot accept it to check i run simple sql query INSERT INTO mytable (myname , mydate ) values ('abc' , 'NULL' ); i also save 0000.00.00 in datebut when i run INSERT INTO mytable (myname , mydate ) values ('abc' , NULL ); see here NULL is without ' ' now it show NULL in database so in php we are using variable to save values in database and variable are under ' ' so i am unable so save NULL in database trhough PHP , i tired i loose
  5. is this code will work under foreach ?????? i m working on array here as u check my code above.
  6. thank you for correct replycan we use && here instead of using two time IF if yes then how i wanna use && operator like thisif(isset($_POST['select'])) && if(isset($a)) ???? what wrong with this code
  7. i already set this field NULL in my database to accept null values actually $etd = date('Y-m-d',strtotime($_POST['etd'][$row]));this line create $etd i have to stop itlike thisif $_POST['etd'][$row] is present then $etd = date('Y-m-d',strtotime($_POST['etd'][$row]));else $etd = ""how i create this line in php code ??? tell me the php code for this issue
  8. i have 3 column delivery_no , qty , etd (etd is date) i have a form with some rows in shape of array like this<tr>delivery_no[]qty[]etd[]</tr> <tr>delivery_no[]qty[]etd[]</tr> below is my php code if(isset($_POST['save'])) { foreach ($_POST['delivery_no'] as $row=>$del_no){ $delivery_no=$del_no; $qty =$_POST['qty'][$row]; $etd = date('Y-m-d',strtotime($_POST['etd'][$row])); // problem is here $query_array = "INSERT INTO ls_detail ( delivery_no, qty, etd)VALUES ( '$delivery_no', '$qty' , '$etd' )";echo "<br />"; if (mysql_query($query_array)){echo "ROW inserted";}}} ?> my question if i enter some date in etd[] field like 10-11-2012 i works fine and save correct value which i entered.butif i leave my etd[] blank and press save button $etd will be 31-12-1969 automatically , how i stop it , why with out any post value in etd field it save date 31-12-1969 in databaseactually my question is why my $etd = 31-12-1969 without $_POST['etd'][$row]and how i set $etd " NULL" if $_POST['etd'][$row] have no valueplease answer me with code thanks in advance
  9. actually i want to check both select and $row[1] because when i press select button it will execute a query and $row[1] is the result of that queryso i want to check if select is pressed and my query has $row[1] then echo it
  10. i have a field field1 value ="<?php if(isset($_POST['submit'])){echo $row[1]; }?>" $row[1] is result because of a query some times $row[1] is present and some times no if not present it generate an error how i set my php code in value to check after submit is $row[1] is present or not to echo it
  11. can you tell me how to set isset to check if variable is present or not with submit buttonlike this i want this type of code if select button is press check $a is present if present echo $a
  12. can you tell me please how to to set isset to check if variable is present please note i already set if isset $_POST['select']
  13. thank you jamesB i will reply you after apply this solution
  14. Thankyou very much this is really is easy solution for me i will inform you after apply this
  15. can u please show the code how you send email on click save
  16. let suppose i have 3 fields in my form field 1 = Namefield 2 = Dept_code (may be it is a combo box or you sugest what i do)Field3= Dept_name i have a table in my mysql databse with 2 fields like this dept_code dept_name1 accounts2 finance3 administration now i starting filling up my form i enter abc in name field Qestion 1 i want my all dept code from database in my dept_code combo box field means 1 2 and 3 Question 2 when i select '1' from list i want "accounts" in field3 because dept_code 1 = accounts in database i know query will be like this select dept_name from table where dept_id = 1 i want very simple php coding to do this i am not expert
  17. i have a text field like this <td width="62"> < input name="delivery_no[]" type="text" size="5" value = " <?php if(isset($_POST['select'])) // i set value here for this field { echo $rows[3]['delivery_no']; // this echo $rows is coming from a sql query } ?>"/></td> problem is that if my sql query has this result it echo here BUT when my sql query has no result my page generate an error i just required if my sql query does not have this $rows[0] my field remains blank and i can continue work on other fields. like thisif sql query has $rows[3] echo it other wise do nothing let field blank
  18. one more problemlet suppose i have 5 rows in my table like this and a button name submitfield1[name] i set value for filed1 value = if (isset=$_POST['submit'])) { echo $rows[0]['name'];} field1[name] i set value for filed1 value = if (isset=$_POST['submit'])) { echo $rows[1]['name'];} field1[name] i set value for filed1 value = if (isset=$_POST['submit'])) { echo $rows[2]['name'];} field1[name] i set value for filed1 value = if (isset=$_POST['submit'])) { echo $rows[3]['name'];} field1[name] i set value for filed1 value = if (isset=$_POST['submit'])) { echo $rows[4]['name'];} problem is this that if $rows[3] or [4] is empty means my query has only three rows then last 2 fields generating errors because i specify value there array [3] and [4]i want if my query has only 2 rows then it will echo first two array [0] [1] but other fields remains empty dont give any error.
  19. one more problem let suppose i have 5 rows in my table like this and a button name submit field1[name] i set value for filed1 value = if (isset=$_POST['submit'])) { echo $rows[0]['name'];} field1[name] i set value for filed1 value = if (isset=$_POST['submit'])) { echo $rows[1]['name'];} field1[name] i set value for filed1 value = if (isset=$_POST['submit'])) { echo $rows[2]['name'];} field1[name] i set value for filed1 value = if (isset=$_POST['submit'])) { echo $rows[3]['name'];} field1[name] i set value for filed1 value = if (isset=$_POST['submit'])) { echo $rows[4]['name'];} problem is this that if $rows[3] or [4] is empty means my query has only three rows then last 2 fields generating errors because i specify value there array [3] and [4]i want if my query has only 2 rows then it will echo first two array [0] [1] but other fields remains empty dont give any error.
  20. thank you soooooooooooooooooooooooooooooooo much i spent almost 2 weeks in this issue acutally i m new in php and also no idea about array thank you sooo much again
  21. i have "perosn" table in database "geotex" with 3 fields dept name and agedate in table like this dept name agemale abc 33male xyz 2female 123 25 i create a table like thisperson.php field1 [dept] field2[name] field3[age]field1 [dept] field2[name] field3[age]field1 [dept] field2[name] field3[age]field1 [dept] field2[name] field3[age] and i have a button with name of "select" now i want to run a sql query select * from person where dept = maleand want to disply result like male in field1 abc in field2 33 in field 3male in field1 xyz in field2 2 in field 3 when i run php code with isset = post[select]then run above query and problem starts from here i use while ($result = mysql_fetch_array($run)) {echo $name = $result ['name'];} // this echo shows both abc and xyz but i wanna show abc name using array position } some body says use foreach but i dont have idea how to use foreach
  22. how to use array to echo result in specific field <?php //$conn=mysql_connect("localhost", "root", "");//$db=mysql_select_db ('geotex', $conn) or die (" error "); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Untitled Document</title></head> <body> i have "perosn" table in database "geotex" with 3 fields ###### age and person date in table like tis ###### name age </br>male abc 33</br>male xyz 2</br>female 123 25 <form action="person.php" method="post"> <table width="299" border="0" cellpadding="3"> <tr> <td width="109"><div align="center">######</div></td> <td width="107"><div align="center">Name</div></td> <td width="57"><div align="center">Age</div></td> </tr></table> <table width="200" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="62"><div align="center"> <input name="######[]" type="text" size="20 " /> </div></td> <td width="62"><div align="center"> <input name="name[]" type="text" value= "<?php // i set value here for this field if (isset ($_POST['select'])) {$sql = "select * from person where ###### = 'male' "; $run = mysql_query($sql); while ($result = mysql_fetch_array($run)) {echo $name = $result ['name'];} // echo shows both abc and xyz but i wanna show abc name using array position }?>" size="20 " /> </div></td> <td width="88"><div align="center"> <input name="age[]" type="text" value= "<?php if (isset ($_POST['select'])) {$sql = "select * from person"; $run = mysql_query($sql); while ($result = mysql_fetch_array($run)) {echo $age = $result ['age'];} // echo shows both 33 and 2 but i wanna show abc age using array position }?>" size="10" /> </div></td> </tr> <tr> <td width="62"><div align="center"> <input name="######[]" type="text" size="20 " /> </div></td> <td width="62"><div align="center"> <input name="name[]" type="text" size="20 " /> </div></td> <td width="88"><div align="center"> <input name="age[]" type="text" size="10" /> </div></td> </tr> </table> <table width="200" border="0" cellpadding="3"> <td width="134"><div align="center"> <input name="select" type="submit" value="SELECT" /> </div></td> </table> </form>i wanna show result with array position mean in first row i need abc in name filed 33 in age field and male in ###### field and xyz in second row as well </body></html>
×
×
  • Create New...