Jump to content

ashrafzia

Members
  • Posts

    45
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

ashrafzia's Achievements

Member

Member (2/5)

0

Reputation

  1. Hi there! I want to display(select) a no from database in a textbox when the username is selected in the listbox. Problem is I can't get the person number. Here's the code: {javascript part} var xmlHttp; function showUser(str) { xmlHttp=GetXmlHttpObject(); if (xmlHttp==null) { alert ("Browser does not support HTTP Request"); return; } var url="names.php"; url=url+"?q="+str; url=url+"&sid="+Math.random(); xmlHttp.onreadystatechange=stateChanged; xmlHttp.open("GET",url,true); xmlHttp.send(null); } function stateChanged() { if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { document.getElementById("p_no").innerHTML=xmlHttp.responseText; } } function GetXmlHttpObject() { var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { //Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; } names.php <?php include("../connection.php"); $q=$_GET["q"]; $sql="SELECT p_no FROM resumes WHERE user_id = '".$q."'"; $result = mysql_query($sql); $row = mysql_fetch_array($result); echo "$row['p_no']"; mysql_close($con); ?>
  2. Hi there! I want to submit multiple arrays from the form elements and then insert records from them inside the table. Any suggestion or code example will be very helpful. Thanks alot.
  3. I am getting the following error by using the header function. I don't know why is it giving error because i am using the same function at other place without any error. Warning: Cannot modify header information - headers already sent by (output started at functions.php:73) in view_ordered_services.php on line 51 Any idea?
  4. I am getting a value from the table of the field no_of_semester. suppose the no_of_semester for the programe BCS are 8. Now i have to put the no_of_semester value in a listbox but the no_of_semester will start from 1,2,3.....8, which will be defenetly done with the help of a loop. I have the following logic applied but doesn't seems to work. <?php include "connection.php"; $prog_name = $_POST['first']; $sql = "SELECT programmes.no_of_semesters FROM programmes WHERE programmes.programe_name = '$prog_name' "; $result = mysql_query($sql, $conn) or die (mysql_error()); while ($row = mysql_fetch_array($result)){ $sem = $row['no_of_semesters']; } $select = "<select id=\"semester\" name=\"semester\"> <option value=\"\">--Select--</option>"; for ($i=1;$i<=$sem;$i++) { $add .= "<option value='$sem[$i]'>$sem[$i]</option>"; echo "$add"; } $select .="</select>"; echo "$select"; ?> Any idea!!
  5. I am sorry. I couldn' get you are trying to say? why should i use include function on the other page? by other page do you mean sublist.php ?
  6. Here's my sublist.php file : <? include "connection.php"; $prog_name = $_GET['prog_name']; echo "$prog_name"; $sql = "SELECT programmes.no_of_semesters FROM programmes WHERE programmes.programe_name = '$prog_name' "; $result = mysql_query($sql, $conn) or die (mysql_error()); while ($row = mysql_fetch_array($result)){ $semester .="<option value='$row[no_of_semesters]'>$row[no_of_semesters]</option>"; } echo "<select name='semester'> <option value=''>--Select--</option> $semester </select>"; ?> Its still not working.....
  7. I have the following code for ajax/php : $form = "<head><title>:::Subjects:::</title></head> <script src='ajax_files/prototype.js'></script> <script src='ajax_files/getSecond.js'></script> <body> <form action='subjects.php' method='get' enctype='multipart/form-data'> <table width='394' border='1' align='center' cellpadding='5' cellspacing='5'> <tr> <td>Programe Name:</td>"; $sql = "select programe_name from programmes"; $result = mysql_query($sql, $conn) or die (mysql_error()); while ($row = mysql_fetch_array($result)){ $add .="<option value='$row[programe_name]'>$row[programe_name]</option>"; } $form .= "<td> <select name='prog_name' id='prog_name' onchange='getSecond(this.value)'> <option value=''>--Select--</option> $add </select> </td> </tr> <tr> <td>Semester:</td> <td><span id=\"comboHint\">"; $include = include('ajax_files/sublist.php'); // i don't know wat to do here? How to include this file? // include "ajax_files/sublist.php"; $form .= "$include</span> </td></tr></table></form></body></html>"; I am actually getting the programe names from the table inside the select box. Now i want whenever a programe name is selected, for e,g bba, a new list box should appear with the total no of semesters for it. i dont know how to put the sublist.php file between <span> </span> tags and run it there. In the sublist.php file i have my list box. And another question is, how can i maintain the format/design of my form? because when i echo the file sublist.php it is showing me the list box on the top left corner instead of inside the cell, which i have mentioned.
  8. Nice mistake pointed out. I didn't realized. Yes, both of them are defined.
  9. Yes it is defined. I have an authentication script and after authenticating a person i am redirecting him to another page through header function and passing his name like this: header("Location: http://localhost/xampp/mypic/pictures.php?user=$_POST[name] "); Then i am getting his name like this: $user = $_GET['user']; Its working fine uptil here. Now when the if....else block statement appears it is hush. I don't know why?
  10. I want the value of the variable $user to go inside the if statement inside the query, but its not working. How can i make the value of the variable $user as a global for access inside if....else block statements. $val = $_GET['id']; $user = $_GET['user']; if ($val == "AddPaper" && !isset($_POST['next_x'])){ //echo "$user"; $sql="SELECT programe_name FROM teachers WHERE teacher_name='$user' "; $result = mysql_query($sql, $conn) or die ("Can't Process Query".mysql_query()); while ($row=mysql_fetch_array($result)){ $add1 .= "<option value='$row[programe_name]'>$row[programe_name]</option>"; } I have a dropdown menu which has a link as http://localhost/xampp/......../myfile?id=AddPaper when i click the button the above if statement is executed but the value of the variable $user isn't coming inside it and before the button click i have a value inside the link as http://localhost/xampp.......myfile?user=$_post[name]. I hope you get what i want to say.
  11. Now lets make this a little complex..... I have got all my programe_names from my table inside a list box. Now i want whenever a progame_name is selected, the no of semesters for a programe which we are also retrieving from the table, let us say for the programe BBA the no of semesters are 8 which is stored inside a table. I want to show all the semester no's from 1,2,3.....8 inside the semester list box. How can i put this logic??? and remember whenever a different programe_name is selected, the no of semesters stored for it in the table should be retrieved and then a loop will be started from 1....upto that No which is retrieved and then those values will be printed inside the listbox. I want to apply all this logic on runtime. Any idea! THanx in Advance.
  12. Excellent logic! THis is what i want to do. Its working cool and fine enough to understand as well.
  13. hm......i admit my fault. I was really repeating the form, which is a big mistake. i have tried your code but its only printing Array inside the listbox not the values. i don't know why?
  14. How can i retrieve values from database table to a list box? I have tried something like this : $sql = "SELECT * from programmes"; $result = mysql_query($sql, $conn) or die(mysql_error()); while ($row = mysql_fetch_array($result)){ $progs = $row['programe_name']; $sems = $row['no_of_semesters']; $form = "<body> <form action='studentregistrationform.php' method='post' enctype='multipart/form-data'> <td>Programe:</td> <td><select name='programe'> <option value='$progs'>$progs</option> </select></td> </tr> <tr> <td>Semester:</td> <td><select name='semester'> <option value='$sems'>$sems</option> </select></td> </table></form>"; } Its working but only last record is showing from the table not all of them both in same programes and semester list box.
×
×
  • 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.