geekisthenewsexy Posted January 16, 2011 Share Posted January 16, 2011 hi all. i am so lost here guys,i need your help. basically, i have 3 pages here. _add_tsubject, _query_subject, and _do_addtsubject. _add_tsubject here contains a livesearch javascript that searches for subjects which i query in _query_subject. the result of that is displayed in _add_tsubject. i am using get method for that and for the url. now, my problem is how to pass or should i say combine the url from _add_tsubject with the url inside the <a href> in _query_subject?or is it possible??i'm sorry if it sounds confusing. but if it's confusing you please have a look at the code.. _add_tsubject <?php include("dbconnection_wmsuipil.php"); $id = $_GET['item']; $t_id = $_GET['t_id']; $lname = $_GET['lname']; $fname = $_GET['fname']; $result= mysql_query("SELECT * FROM tblSetSY")or die(mysql_error()); while($row = mysql_fetch_array($result)) { $setYear=$row['SchoolYear']; $setSem=$row['Sem']; } ?> <!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=utf-8"/> <title>Adding subject to teacher..</title> <link rel="stylesheet" href="style.css"/> <link rel="stylesheet" href="validator_style/screen.css"/> </head> <body> <div style="margin-right:30px; padding:10px;" align="right"><a href="#" onclick="window.location.reload()">Reload</a> | <a href="#" onclick="window.close()">Close</a></div> <form name="form" id="cmxform_sched" class="cmxform" method="post" action="_do_addtsubject.php"> <fieldset> <p> <label for="t_id">Teacher ID: </label> <input type="hidden" name="school_year1" value="<?php echo $setYear;?>"/> <input type="hidden" name="sem1" value="<?php echo $setSem;?>"/> <input type="hidden" name="id" value="<?php echo $id;?>" size="15"/> <input type="text" name="t_id" value="<?php echo $t_id;?>" size="15"/> </p> <p> <label for="name">Name: </label> <input type="text" name="name" value="<?php echo $fname.' '.$lname;?>" size="25"/> </p> <p><i>*Add subjects to be handled...</i></p> <p><label for="keyword">Enter Subject ID: </label> <input type="text" name="sid" id="sid" size="15" onkeyup="showResult(this.value)" /> </p> <div id="livesearch" align="center"><b>->Subject info will be listed here<-</b></div> </table> </fieldset> </form> <script type="text/javascript"> function showResult(str) { if (str.length==0) { document.getElementById("livesearch").innerHTML=""; document.getElementById("livesearch").style.border="0px"; 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("livesearch").innerHTML=xmlhttp.responseText; document.getElementById("livesearch").style.border="1px solid #A5ACB2"; } } xmlhttp.open("GET","_query_subject.php?q="+str,true); xmlhttp.send(); } </script> </body> </html> _query_subject (i get an error on the _POST here..) <?php include("dbconnection_wmsuipil.php"); $t_id=$_POST['t_id']; $name=$_POST['name']; $sy=$_POST['school_year1']; $sem=$_POST['sem1']; $q=$_GET['q']; $sql="SELECT * FROM admin_subject WHERE subj_id like '%".$q."%'"; echo "<table border='1'> <tr> <th>#ID</th> <th>Subject ID</th> <th>Subject Code</th> <th>Description</th> <th>Lect</th> <th>Lab</th> <th>Units</th> </tr>"; $result = mysql_query($sql); while($row = mysql_fetch_array($result)) { $OutLine = array('id'=>'','subj_id'=>'','subj_code'=>'','subj_desc'=>'','lecture'=>'','laboratory'=>'','units'=>''); $OutLine['id'] = $row['id']; $OutLine['subj_id'] = $row['subj_id']; $OutLine['subj_code'] = $row['subj_code']; $OutLine['subj_desc'] = $row['subj_desc']; $OutLine['lecture'] = $row['lecture']; $OutLine['laboratory'] = $row['laboratory']; $OutLine['units'] = $row['units']; $countTsubj=0; if($row>$countTsubj) { echo "<tr>"; echo "<td>".implode('<td/>',$OutLine); echo '<td><a href="_do_addtsubject.php?id='.$row['id'].'&subj_id='.$row['subj_id'].'&code='.$row['subj_code'].'&desc='.$row['subj_desc'].'&lect='.$row['lecture'].'&lab='.$row['laboratory'].'&units='.$row['units'].'">[Add]</a></td>'; echo "</tr>"; } } echo "</table>"; ?> _do_addtsubject <?php include("dbconnection_wmsuipil.php"); $t_id=$_POST['t_id']; $name=$_POST['name']; $sy=$_POST['school_year1']; $sem=$_POST['sem1']; $id=$_GET['id']; $subj_id=$_GET['subj_id']; $code=$_GET['code']; $desc=$_GET['desc']; $lect=$_GET['lect']; $lab=$_GET['lab']; $units=$_GET['units']; echo $t_id; echo $name; echo $sy; echo $sem; echo $id; echo $subj_id; echo $code; echo $desc; echo $lect; echo $lab; echo $units; ?> there guys..i hope you can help me..the last page is where plan to echo the url once it's combined..please please help.. Quote Link to comment https://forums.phpfreaks.com/topic/224597-help-with-passing-url-not-the-usual/ Share on other sites More sharing options...
requinix Posted January 16, 2011 Share Posted January 16, 2011 I'm pretty sure there are other problems besides this one... but at 1am I'm not really in shape for it. Your AJAX isn't sending any POST data. Regardless of everything else you've done to generate the page, if you want _query_subject.php to get POST data you have to send it manually. Such as xmlhttp.open("POST","_query_subject.php?q="+str,true); xmlhttp.send("t_id=123&name=xyz&..."); I recommend you use a JavaScript library for all this stuff. Saves you the hassle of creating the XMLHttpRequest object and managing the whole AJAX nonsense. Quote Link to comment https://forums.phpfreaks.com/topic/224597-help-with-passing-url-not-the-usual/#findComment-1160208 Share on other sites More sharing options...
geekisthenewsexy Posted January 16, 2011 Author Share Posted January 16, 2011 thanks for the response requinix. i'm kind of new to javascript as well as ajax so i'm kind of lost..can you show me an example of that?or is there another way to do it with less hassle? Quote Link to comment https://forums.phpfreaks.com/topic/224597-help-with-passing-url-not-the-usual/#findComment-1160220 Share on other sites More sharing options...
geekisthenewsexy Posted January 17, 2011 Author Share Posted January 17, 2011 .....anyone??.. :'( please tell me if it's not clear... Quote Link to comment https://forums.phpfreaks.com/topic/224597-help-with-passing-url-not-the-usual/#findComment-1160489 Share on other sites More sharing options...
requinix Posted January 17, 2011 Share Posted January 17, 2011 If you're as new as you say then you should use a library instead of trying to do it all yourself. Try jQuery. Download the files, read the API (at least the relevant bits), and see what you can do with it. Quote Link to comment https://forums.phpfreaks.com/topic/224597-help-with-passing-url-not-the-usual/#findComment-1160502 Share on other sites More sharing options...
geekisthenewsexy Posted January 17, 2011 Author Share Posted January 17, 2011 ..sigh..i just like to know if it's possible if i use the method i'm used to? and, the codes below are i think more simple for me because i'm used to it.. anyway,my remaining problem there is getting the value from _add_tsubject (this is a pop-up window when i click on a link on the parent page),the value of 'teacher_id' and 'name' thru the url..but as of now, i only get the value of <a href="_do_addtsubject.php?id='.$row['id'].'&subj_id='.$row['subj_id'].'&code='.$row['subj_code'].'&desc='.$row['subj_desc'].'&lect='.$row['lecture'].'&lab='.$row['laboratory'].'&units='.$row['units'].'">[Add]</a> ..if there's a way of getting the 'teacher_id' and 'name' from _add_tsubject by using the method below and combining it with url from '_do_addtsubject' then i just use that kind of method.... Quote Link to comment https://forums.phpfreaks.com/topic/224597-help-with-passing-url-not-the-usual/#findComment-1160513 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.